using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using YookingBizYQ.Class.Public;
using YookingDBNormal.Class;
using YookingFileIO.Class;
using YookingKitBox.Class.Public;
using YookingSvrDBCall.Class.DBLogic;
using YookingSvrDBCall.Class.DBPub;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace YookingBizYQ
{
    public class clsYaraApi
    {

        //注释 ： 杨奇  2024年 9月  15 日=============================================================
        //该方法为开发环境调试 查询类 SQL语句使用 ，不作生产环境使用
        ////打印日志
        //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
        //myLog.WriteInfoToTxtFile("SysLog", "yangqi_进入 参数.txt", strRequestData);

        public string GetList(string strB64RequestData) {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            string sqlStr = strArray[1];

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(sqlStr);
            sbQuerySQL.AppendLine();

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        // 注释： 杨奇 2024年9月15 ================================================================
        //  添加修改
        public string InsertOrUpdate(string strB64RequestData)
        {
            string strRtData = "no data"; //最终的写库结果

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strDBGroup = "Data";         //数据库分组名
            string strDBTblName = "TableAA";    //库表名称
            string strKeyColSet = "aa,bb,cc";   //需要判断是否重值的字段名，支持可以多个字段
            string strUserName = "02120119901"; //客户端用户名
            string strJsonArray = "[{null}]";   //将要向数据库中写入的真实数据内容

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 5)
            {
                strDBGroup = strArray[0];
                strDBTblName = strArray[1];
                strKeyColSet = strArray[2];
                strUserName = strArray[3];
                strJsonArray = strArray[4];
            }

            #endregion

            DataSet dsData = clsJConvert.JArryToDataSet(strJsonArray); //将Json数组转成DataSet

            clsWriteDB myWrite = new clsWriteDB(); //先判断数据是否存在，根据判断结果自动执行insert或者update
            strRtData = myWrite.WriteDBNormal_UseSYSCol(strDBGroup, strDBTblName, strKeyColSet, strUserName, dsData);

            return strRtData; //数据库操作的最终结果

        }
        //  注释： 杨奇 2024年9月15 ================================================================
        //注销数据
        public string CancelDataForRecordID(string strB64RequestData)
        {
            object objResult = 0; //受影响的行数

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "Test"; //库表名称
            string strCancelUserName = "02120119901"; //注销操作者
            string strCancelDateTime = "1900-01-01 00:00:00"; //注销日期时间值
            string strCancelReason = "未说明"; //注销原因
            string strRecordID = "0000000000"; //待注销的记录ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 6)
            {
                strDBGroup = strArray[0];
                strDBTblName = strArray[1];
                strCancelUserName = strArray[2];
                strCancelDateTime = strArray[3];
                strCancelReason = strArray[4];
                strRecordID = strArray[5];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbUpdateSQL = new StringBuilder();
            sbUpdateSQL.AppendLine(" UPDATE " + strDBTblName + " SET ");
            sbUpdateSQL.AppendLine("  SYS_CANCELUSERNAME='" + strCancelUserName + "', ");
            sbUpdateSQL.AppendLine("  SYS_CANCELDATETIME='" + strCancelDateTime + "', ");
            sbUpdateSQL.AppendLine("  SYS_CANCELREASON='" + strCancelReason + "' ");
            sbUpdateSQL.AppendLine(" WHERE ");
            sbUpdateSQL.AppendLine("  SYS_RECORDID='" + strRecordID + "' ");

            #endregion

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            objResult = myDB.YookingExecuteNonQuery(strDBGroup, sbUpdateSQL.ToString());

            return objResult.ToString(); //返回数据库操作的结果
        }

        // ==========================资产类别页面相关查询=================================
        //查询资产分类一级列表  不需要SF验证
        public string GetPreantTypePropertyList(string strB64RequestData)
        {
            string strRtData = "no data";

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_type_property"; //主表库名称
            string procurementType = ""; //采购类型 1 固定资产 2 非固定资产

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            procurementType = strArray[0];

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT typeID, typeName, SYS_RECORDID AS strRecordID,DepreciationMonth FROM " + strDBTblName);
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND pID = '0' ");
            sbQuerySQL.AppendLine(" AND UnitCode = '" + strArray[1] + "' ");  //strArray[1]
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            string str = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            if (!"{\"result\":\"yooking null\"}".Equals(str))
            {
                strRtData = JArray.Parse(str).ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData; //数据库查询结果
        }
        //查询资产分类列表详情 不需要SF验证
        public string GetTypePropertyList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_type_property"; //主表库名称
            string procurementType = ""; //采购类型 1 固定资产
            string typeName = ""; //名称
            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            procurementType = strArray[0];
            typeName = strArray[1];

            StringBuilder sbQuerySQL = new StringBuilder();
            //查询列表
            // 查询一次数据库 在分级处理数据
            sbQuerySQL.AppendLine("SELECT typeID,pID, typeNumber,typeName, description,IsNullSN, SYS_RECORDID AS strRecordID ,DepreciationMonth  FROM " + strDBTblName);
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND UnitCode = '" + strArray[2] + "' ");
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(typeName))
            {
                sbQuerySQL.AppendLine(" AND typeName like '%" + typeName + "%' ");
            }
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //查询数据
            string str = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            if (!"{\"result\":\"yooking null\"}".Equals(str))
            {
                JArray arr = JArray.Parse(str);
                JArray arr2 = new JArray();//一级列表
                foreach (JObject item in arr)
                {
                    if ((string)item["pID"] == "0")
                    {
                        arr2.Add(item);
                    }
                }
                foreach (JObject item in arr2)
                {
                    JArray arr3 = new JArray();//二级列表
                    foreach (JObject item1 in arr)
                    {
                        if ((string)item1["pID"] == (string)item["typeID"])
                        {
                            arr3.Add(item1);
                        }
                    }
                    item.Add("children", arr3);
                }
                strRtData = arr2.ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData; //数据库查询结果
        }

        // ==========================资产采购界面相关查询=================================
        //查询资产类别列表
        public string GetTypePropertyNameList(string strB64RequestData)
        {
            string strRtData = "no data";

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_type_property"; //主表库名称
            string procurementType = ""; //采购类型 1 固定资产 2 非固定资产

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            procurementType = strArray[0];
            StringBuilder sbQuerySQL = new StringBuilder();
            //查一次数据库 再分级处理数据
            sbQuerySQL.AppendLine("SELECT typeID AS value,pID, typeName AS label, SYS_RECORDID AS strRecordID FROM " + strDBTblName);
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND UnitCode = '" + strArray[1] + "' ");
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            string str = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());


         

            if (!"{\"result\":\"yooking null\"}".Equals(str))
            {
                JArray arr = JArray.Parse(str);
                JArray arr2 = new JArray();//一级列表
                foreach (JObject item in arr)
                {
                    if ((string)item["pID"] == "0")
                    {
                        arr2.Add(item);
                    }
                }
                foreach (JObject item in arr2)
                {
                    JArray arr3 = new JArray();//二级列表
                    foreach (JObject item1 in arr)
                    {
                        if ((string)item1["pID"] == (string)item["value"])
                        {
                            arr3.Add(item1);
                        }
                    }
                    item.Add("children", arr3);
                }
                strRtData = arr2.ToString();
            } else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData; //数据库查询结果
        }


        /// <summary>
        /// 查询当前用户的登录日志 by UserMobleNumber
        /// </summary>
        /// <param name="strB64RequestData"></param>
        /// <returns></returns>
        public string GetLoginlog(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "op_userloginlog"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数  
            string PERSONNAME = "";//用户电话
            string UNITCODE = "";//公司代码
            string DEPTCODE = "";//部门代码
            string UserID = "";//用户ID

            string roleName = "";//角色名称


            //string TypeID = "";
            //string userDepartmentID = "";

            //这些参数用★分隔开，客户端与服务器端要一致   8 9 (部门id-人员id)
           // var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ PersonName}★${ UNITCODE}★${ DEPTCODE}`;
            string[] strArray = strRequestData.Split('★');
            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            PERSONNAME = strArray[2]; //用户名称           uni
            UNITCODE= strArray[3];
            DEPTCODE= strArray[4];
            

            string sf = getPersonneInfo(roleName); //通过角色得到身份

            //TypeID = strArray[2];   //类别id
            //userDepartmentID = strArray[3]; //部门id
            //统计条数
            StringBuilder sbTotalySQL = new StringBuilder();
            sbTotalySQL.AppendLine("SELECT COUNT(*) AS total FROM " + strDBTblName);
            sbTotalySQL.AppendLine(" WHERE ");
            sbTotalySQL.AppendLine(" 1 = 1 ");
            if (sf.Equals("0"))
            {
                sbTotalySQL.AppendLine(" and  PERSONNAME = '" + PERSONNAME + "' ");
            }
            if (sf.Equals("10"))
            {
                sbTotalySQL.AppendLine(" and  DEPTCODE = '" + DEPTCODE + "' ");
            }

            //sbTotalySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
           // sbTotalySQL.AppendLine(" and  UserName = '" + UserMobleNumber + "' ");
            sbTotalySQL.AppendLine(" AND UNITCODE = '" + UNITCODE + "' ");
          //  sbTotalySQL.AppendLine(" 1 = 1 ");

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalySQL.ToString());
            JObject o = new JObject();

            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                o.Add("totalNum", 0);
                o.Add("list", new JArray());
            }
            else
            {
                //起始条数
                int startNum = (pageNum - 1) * pageSize;

                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT * FROM " + strDBTblName + " ");
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(" 1 = 1 ");
                if (sf.Equals("0"))
                {
                    sbQuerySQL.AppendLine(" and  PERSONNAME = '" + PERSONNAME + "' ");
                }
                if (sf.Equals("10"))
                {
                    sbQuerySQL.AppendLine(" and  DEPTCODE = '" + DEPTCODE + "' ");
                }
                //sbTotalySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
               //
                //sbQuerySQL.AppendLine("  WHERE  ");
                //sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                //sbQuerySQL.AppendLine(" AND departmentID = '" + userDepartmentID + "' ");
                //sbQuerySQL.AppendLine(" AND TypeID = '" + TypeID + "' ");

                sbQuerySQL.AppendLine("ORDER BY Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + startNum + " , " + pageSize);
                //获取列表详情
                string listStr = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                JArray list = JArray.Parse(listStr);
                o.Add("totalNum", oo["total"].Value<int>());
                o.Add("list", list);

            }

            strRtData = o.ToString();
            return strRtData; //数据库查询结果

        }


        //分页查询当前部门，当前资产类别下的资产。
        public string GetDepTypeP(string strB64RequestData) {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_property_detail"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数

            string TypeID = "";
            string userDepartmentID = "";

            //这些参数用★分隔开，客户端与服务器端要一致   8 9 (部门id-人员id)
            string[] strArray = strRequestData.Split('★');
            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            TypeID = strArray[2];   //类别id
            userDepartmentID = strArray[3]; //部门id
            //统计条数
            StringBuilder sbTotalySQL = new StringBuilder();
            sbTotalySQL.AppendLine("SELECT COUNT(*) AS total FROM " + strDBTblName);
            sbTotalySQL.AppendLine(" WHERE ");
            sbTotalySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalySQL.AppendLine(" AND departmentID = '" + userDepartmentID + "' ");
            sbTotalySQL.AppendLine(" AND TypeID = '" + TypeID + "' ");

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalySQL.ToString());
            JObject o = new JObject();

            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                o.Add("totalNum", 0);
                o.Add("list", new JArray());
            }
            else {
                //起始条数
                int startNum = (pageNum - 1) * pageSize;
          
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT receiptTime,departmentName,userName,propertyName,propertyNumber FROM " + strDBTblName + " ");
                sbQuerySQL.AppendLine("  WHERE  ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND departmentID = '" + userDepartmentID + "' ");
                sbQuerySQL.AppendLine(" AND TypeID = '" + TypeID + "' ");
                sbQuerySQL.AppendLine("ORDER BY Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + startNum + " , " + pageSize);
                //获取列表详情
                string listStr = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                JArray list = JArray.Parse(listStr);
                o.Add("totalNum", oo["total"].Value<int>());
                o.Add("list", list);

            }

            strRtData = o.ToString();
            return strRtData; //数据库查询结果

        }




        //分页查询资产采购列表
        public string GetBuyPropertyList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_buy_property"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string procurementType = ""; //采购类型 1 固定资产
            string propertyName = ""; //资产名称
            string applicantName = "";//申请人
            string sDate = "";//采购开始日期
            string eDate = "";//采购结束日期
            string TypeID = "";//资产类别ID
            //string userDepartmentID = "";
            //string userID = "";
            string state = "";
            string DeptCode = "";
            string PersonCode = "";
            string UnitCode = "";
            string purchaseOrderNumber = "";
            string RoleName = "";
            //这些参数用★分隔开，客户端与服务器端要一致   8 9 (部门id-人员id)
            string[] strArray = strRequestData.Split('★');
            //var strRequestData = `${jsonObj.pageNum}★${jsonObj.pageSize}★${jsonObj.procurementType}★${jsonObj.propertyName}★${jsonObj.applicantName}★${jsonObj.sDate}★${jsonObj.eDate}
            //★${jsonObj.TypeID}★${jsonObj.state}★${ObjToStr(localStorage_getValue("DeptCode"))}★${ObjToStr(localStorage_getValue("PersonCode"))}★${ObjToStr(localStorage_getValue("UnitCode"))}
            //★${jsonObj.purchaseOrderNumber}`;  
           // strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}`

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            procurementType = strArray[2];
            propertyName = strArray[3];
            applicantName = strArray[4];
            sDate = strArray[5];
            eDate = strArray[6];
            TypeID = strArray[7];
            state= strArray[8];
            DeptCode = strArray[9];
            PersonCode = strArray[10];
            UnitCode = strArray[11];
            purchaseOrderNumber = strArray[12];
            RoleName = strArray[13];


            //string sf = GetSF(strArray[9], strArray[10]);

            string sf = getPersonneInfo(strArray[13]);

            //获取符合条件的总条数
            #region 统计总条数
            StringBuilder sbTotalySQL = new StringBuilder();
            sbTotalySQL.AppendLine("SELECT COUNT(*) AS total FROM " + strDBTblName);
            sbTotalySQL.AppendLine(" WHERE ");
            sbTotalySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalySQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");


            if ("0".Equals(sf))
            {
                sbTotalySQL.AppendLine(" AND ( userID = '" + PersonCode + "'  OR applicantID = '" + PersonCode + "') ");
            }
            if (!string.IsNullOrEmpty(applicantName))
            {
                sbTotalySQL.AppendLine(" AND (applicantName = '" + applicantName + "' or userName ='" + applicantName + "') ");
            }
            if ("10".Equals(sf))
            {
                sbTotalySQL.AppendLine(" AND userDepartmentID = '" + DeptCode + "' ");
            }

            if ("20".Equals(sf))
            {
               // sbTotalySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
            }

            if ("30".Equals(sf))
            {
                // sbTotalySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
            }


            if ("100".Equals(sf))
            {
                // sbTotalySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
            }


            if ("200".Equals(sf))
            {
                // sbTotalySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
            }


            if ("300".Equals(sf))
            {
                // sbTotalySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
            }

            if ("999".Equals(sf))
            {
                // sbTotalySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
            }



            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalySQL.AppendLine(" AND propertyName like '%" + propertyName + "%' ");
            }

            if (!string.IsNullOrEmpty(sDate) && !string.IsNullOrEmpty(eDate))
            {
                sbTotalySQL.AppendLine(" AND DATE(STR_TO_DATE(procurementTime, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }
            if (!string.IsNullOrEmpty(TypeID))
            {
                sbTotalySQL.AppendLine(" AND TypeID = '" + TypeID + "' ");
            }
            if (!string.IsNullOrEmpty(state))
            {
                sbTotalySQL.AppendLine(" AND state = '" + state + "' ");
            }

            if (!string.IsNullOrEmpty(purchaseOrderNumber))
            {
                sbTotalySQL.AppendLine(" AND purchaseOrderNumber = '" + purchaseOrderNumber + "' ");
            }



            clsRWFile myLo1g = new clsRWFile(); //将待执行的SQL语句记录下来
            myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt", sbTotalySQL.ToString());


            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalySQL.ToString());
            JObject o = new JObject();

            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                o.Add("totalNum", 0);
                o.Add("list", new JArray());
            }
            else
            {
                //起始条数
                int startNum = (pageNum - 1) * pageSize;
                #region 生成查询sql语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT buyID,p.IsNullSN,d.IsZP,p.typeName,d.procurementType, taxRate,budgetUnitPrice, d.TypeID, userID, userName, userDepartmentID,userDepartment, purchaseOrderNumber,propertyName,brand,modelNumber,number,state,applicantName,procurementTime,dqsNum, budgetUnitPrice, d.SYS_RECORDID AS strRecordID, modelDescribe,d.description,spYJ,Dstate,Dinfo FROM " + strDBTblName + " AS d ");
                sbQuerySQL.AppendLine(" LEFT JOIN yara_type_property AS p ON p.typeID = d.TypeID ");
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND d.UnitCode = '" + UnitCode + "' ");
                ////////////////
                if ("0".Equals(sf))
                {
                    sbQuerySQL.AppendLine(" AND ( d.userID = '" + PersonCode + "'  OR d.applicantID = '" + PersonCode + "') ");
                }
                if ("10".Equals(sf))
                {
                    sbQuerySQL.AppendLine(" AND d.userDepartmentID = '" + DeptCode + "' ");
                }

                if ("20".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
                }

                if ("30".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
                }


                if ("100".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
                }


                if ("200".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
                }


                if ("300".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
                }

                if ("999".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND userDepartmentID = '" + userDepartmentID + "' ");
                }


                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND d.procurementType = '" + procurementType + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND d.propertyName like '%" + propertyName + "%' ");
                }
                //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
                //myLog.WriteInfoToTxtFile("SysLog", "fyb10.txt", sbQuerySQL.ToString() + ":::::"+ string.IsNullOrEmpty(applicantName)+ " ++ " + applicantName + DateTime.Now);

                if (!string.IsNullOrEmpty(applicantName))
                {
                    sbQuerySQL.AppendLine(" AND (d.applicantName = '" + applicantName + "' or d.userName ='" + applicantName + "') ");
                }
                if (!string.IsNullOrEmpty(sDate) && !string.IsNullOrEmpty(eDate))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(d.procurementTime, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                if (!string.IsNullOrEmpty(TypeID))
                {
                    sbQuerySQL.AppendLine(" AND d.TypeID = '" + TypeID + "' ");
                }
                if (!string.IsNullOrEmpty(state))
                {
                    sbQuerySQL.AppendLine(" AND d.state = '" + state + "' ");
                }

                if (!string.IsNullOrEmpty(purchaseOrderNumber))
                {
                    sbQuerySQL.AppendLine(" AND d.purchaseOrderNumber = '" + purchaseOrderNumber + "' ");
                }


                sbQuerySQL.AppendLine("ORDER BY d.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + startNum + " , " + pageSize);
                clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
                myLog.WriteInfoToTxtFile("SysLog", "fyb10.txt", sbQuerySQL.ToString() + ":::::"+ string.IsNullOrEmpty(applicantName)+ " ++ " + applicantName + DateTime.Now);
                #endregion

                //获取列表详情
                string listStr = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                JArray list = JArray.Parse(listStr);

                //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
                //myLog.WriteInfoToTxtFile("SysLog", "fyb.txt", sbQuerySQL.ToString()+" ++ "+applicantName+DateTime.Now);

                foreach (JObject i in list)
                {
                    StringBuilder sbCountSQL = new StringBuilder();
                    sbCountSQL.AppendLine("SELECT p.typeName as typeNameCount , COUNT(d.detailID) AS total FROM yara_property_detail AS d ");
                    sbCountSQL.AppendLine("LEFT JOIN yara_type_property AS p ON p.typeID = d.TypeID ");
                    sbCountSQL.AppendLine("WHERE ");
                    sbCountSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
                    sbCountSQL.AppendLine(" AND d.TypeID = '" + i["TypeID"] + "' ");
                    sbCountSQL.AppendLine(" AND d.departmentID = '" + i["userDepartmentID"] + "' ");

                    string count = myDB.YookingExecuteJson(strDBGroup, sbCountSQL.ToString());
                    if ("{\"result\":\"yooking null\"}".Equals(count))
                    {
                        i.Add("count",0);
                        i.Add("typeNameCount", "");
                    }
                    else
                    {
                        JObject ooo = JArray.Parse(count)[0] as JObject;
                        i.Add("count", ooo["total"].Value<int>());
                        i.Add("typeNameCount", ooo["typeNameCount"].ToString());
                    }
                }
                o.Add("totalNum", oo["total"].Value<int>());
                o.Add("list", list);
            }
            strRtData = o.ToString();
            return strRtData; //数据库查询结果
        }
        //导出资产采购列表 未实现
        public string ExportBuyPropertyList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_buy_property"; //主表库名称
            string procurementType = ""; //采购类型 1 固定资产
            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            procurementType = strArray[0];

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT purchaseOrderNumber,typeName,brand,modelNumber,number,budgetUnitPrice,taxRate,state,applicantName,CreatedAt FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(procurementType))
            {

                sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取列表详情
            strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }
        //根据采购ID获取采购单详情(查看按钮)
        public string GetBuyPropertyInfoByBuyID(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_buy_property"; //主表库名称
            string buyID = ""; //采购单ID
            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            buyID = strArray[1];
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT bp.buyID,bp.purchaseOrderNumber,bp.applicantName,bp.CreatedAt,tp.typeNumber,tp.typeName,bp.brand,bp.modelNumber,bp.number,bp.budgetUnitPrice,bp.taxRate,bp.description FROM " + strDBTblName + " AS bp");
            sbQuerySQL.AppendLine(" LEFT JOIN yara_type_property AS tp ON bp.typeID = tp.typeID ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "bp.SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND tp.buyID = '" + buyID + "' ");

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取采购单详情
            string str = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            if (!"{\"result\":\"yooking null\"}".Equals(str))
            {
                //获取采购单下的物品详情列表
                StringBuilder queryByIDSQL = new StringBuilder();
                queryByIDSQL.AppendLine("SELECT detailID, propertyName,brands,modelNumber,propertyPrice,serialNumber FROM yara_property_detail WHERE ");
                queryByIDSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME"));
                queryByIDSQL.AppendLine(" AND buyID = '" + buyID + "'");
                string list = myDB.YookingExecuteJson(strDBGroup, queryByIDSQL.ToString());
                JObject obj = new JObject();
                obj.Add("info", str);
                if ("{\"result\":\"yooking null\"}".Equals(list))
                {
                    obj.Add("list", new JArray());
                }
                else
                {
                    obj.Add("list", JArray.Parse(list));
                }
                strRtData = obj.ToString();
            }
            return strRtData; //数据库查询结果
        }
        //根据采购ID获取待签收单
        public string GetAwaitingDeliveryListByBuyID(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_property_detail"; //主表库名称
            string buyID = ""; //采购单ID
            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            buyID = strArray[0];

            # region 获取待签收采购单的数据
            StringBuilder sbBuySQL = new StringBuilder();
            sbBuySQL.AppendLine("SELECT bp.applicantDepartment, bp.userName, bp.description, bp.spYJ FROM yara_buy_property AS bp");
            sbBuySQL.AppendLine("WHERE ");
            sbBuySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "bp.SYS_CANCELDATETIME "));
            sbBuySQL.AppendLine(" AND bp.buyID = '" + buyID + "' ");

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            string str = myDB.YookingExecuteJson(strDBGroup, sbBuySQL.ToString());

            if ("{\"result\":\"yooking null\"}".Equals(str))
            {
                return "";
            }
            JArray arr = JArray.Parse(str);
            if (arr.Count <= 0)
            {
                return "";
            }
            JObject obj = arr[0] as JObject;
            #endregion

            #region 获取待签收采购单下所有物品列表
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT detailID,propertyNumber,propertyName,propertyPrice,serialNumber,procureNumber,userName,receiptTime FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND buyID = '" + buyID + "' ");

            //获取采购单下的物品详情列表
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                obj.Add("list", JArray.Parse(list));
                #region 获取签收单总价
                StringBuilder sbSumSQL = new StringBuilder();
                sbSumSQL.AppendLine("SELECT SUM(propertyPrice) AS totalPrice FROM " + strDBTblName + " ");
                sbSumSQL.AppendLine("WHERE ");
                sbSumSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                sbSumSQL.AppendLine(" AND buyID = '" + buyID + "' ");

                string price = myDB.YookingExecuteJson(strDBGroup, sbSumSQL.ToString());

                JObject o = JArray.Parse(price)[0] as JObject;
                obj.Add("totalPrice", o["totalPrice"].Value<double>());
                #endregion
            }
            else
            {
                obj.Add("list", new JArray());
                obj.Add("totalPrice", 0);
            }
            #endregion
            strRtData = obj.ToString();
            return strRtData; //数据库查询结果
        }
        //采购申请单打印 未实现
        public string GetApplyNote(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_property_detail"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }
        //采购签收单打印 未实现
        public string GetSignForNote(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_property_detail"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }

        // ======================资产明细管理页面相关接口=====================
        //分页获取资产明细列表
        public string GetPropertyDetailList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            // var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ jsonObj.procurementType}★${ jsonObj.typeID}★${ jsonObj.propertyNumber}★${ jsonObj.propertyName}
            // ★${ jsonObj.serialNumber}★${ jsonObj.userID}★${ jsonObj.state}★${ jsonObj.sDate}★${ jsonObj.eDate}★${ jsonObj.DeptCode}★${ jsonObj.userID}★${ ObjToStr(localStorage_getValue("UnitCode"))}`;
            //   strRequestData = strRequestData+`★${ObjToStr(localStorage_getValue("RoleName"))}★${ObjToStr(localStorage_getValue("PersonCode"))}`

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_property_detail"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string procurementType = ""; //采购类型 1 固定资产 2 非固定资产
            string typeID = "";//资产类别ID
            string propertyNumber = ""; //资产编号
            string propertyName = ""; //资产名称
            string serialNumber = ""; //机身序号
            string userID = ""; //使用人id
            string state = ""; //状态
            string sDate = "";//最后操作开始日期
            string eDate = "";//最后操作结束日期
            string deptCode = "";//部门
            string personCode = "";//人员
            string roleName = "";//角色名称中文
            string UnitCode = "";//公司unit
             

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');   ///传回的strArray[12] 也是userID

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            procurementType = strArray[2];
            typeID = strArray[3];
            propertyNumber = strArray[4];
            propertyName = strArray[5];
            serialNumber = strArray[6];
            userID = strArray[7];
            state = strArray[8];
            sDate = strArray[9];
            eDate = strArray[10];
            deptCode = strArray[11];
            UnitCode = strArray[13];
            roleName= strArray[14];
            personCode = strArray[15];


            //string sf = GetSF(deptCode, personCode);
            string sf = getPersonneInfo(roleName);//0:普通员工，仅看自己的  10：部门经理  20：总监  30：总经理  200：行政管理员  100：财务管理员  300：人事管理员  999：超级管理员




            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(d.detailID) AS total FROM " + strDBTblName + " AS d ");
            sbTotalSQL.AppendLine("LEFT JOIN Sa_Org_PersonInfo AS p ON p.PERSONCODE = d.userID ");
            sbTotalSQL.AppendLine(" WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND d.UnitCode = '" + UnitCode + "' ");


            if ("0".Equals(sf))  
            {
                sbTotalSQL.AppendLine(" AND d.userID = '" + personCode + "' ");
            }
            if ("10".Equals(sf))

            {
                sbTotalSQL.AppendLine(GetLineMangerAllDeptCode(personCode, UnitCode, "d.departmentID"));
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + deptCode + "' ");
            }

            if ("20".Equals(sf))
            {
               // sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");

            }

            if ("30".Equals(sf))
            {
               // sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }

            if ("100".Equals(sf))
            {
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }

            if ("200".Equals(sf))
            {
               // sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }

            if ("300".Equals(sf))
            {
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }
            if ("999".Equals(sf))
            {
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }


            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND d.procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(typeID))
            {
                sbTotalSQL.AppendLine(" AND d.typeID = '" + typeID + "' ");
            }
            if (!string.IsNullOrEmpty(propertyNumber))
            {
                sbTotalSQL.AppendLine(" AND d.propertyNumber = '" + propertyNumber + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalSQL.AppendLine(" AND d.propertyName like '%" + propertyName + "%' ");
            }
            if (!string.IsNullOrEmpty(serialNumber))
            {
                sbTotalSQL.AppendLine(" AND d.serialNumber = '" + serialNumber + "' ");
            }

            if (!string.IsNullOrEmpty(userID))
            {
                sbTotalSQL.AppendLine(" AND d.userID = '" + userID + "' ");
            }

            if (!string.IsNullOrEmpty(state))
            {
                if ("5".Equals(state))
                {
                    sbTotalSQL.AppendLine(" AND d.state = '5' ");
                }
                else
                {
                    sbTotalSQL.AppendLine(" AND d.state != '5' ");
                }
            }
            if (!string.IsNullOrEmpty(sDate))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE(d.Sys_InputDateTime, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }
            sbTotalSQL.AppendLine("ORDER BY d.Sys_InputDateTime DESC ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类



            clsRWFile myLogT = new clsRWFile(); //将待执行的SQL语句记录下来
            myLogT.WriteInfoToTxtFile("SysLog", "fyb20250702.txt", sbTotalSQL.ToString());

            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                ///// StringBuilder sbGdTotalSQL = new StringBuilder();
                //sbGdTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_property_detail ");
                //sbGdTotalSQL.AppendLine("WHERE ");
                //sbGdTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                //sbGdTotalSQL.AppendLine(" AND procurementType = '1'");
                //if (sf.Equals("0"))
                //{
                //    sbGdTotalSQL.AppendLine(" AND userID = '" + UserId + "'");
                //}
                //if (sf.Equals("10"))
                //{
                //    sbGdTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "'");
                //}

                //sbGdTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT d.*,p.WorkNumber,tp.DepreciationMonth FROM " + strDBTblName + " AS d ");
                sbQuerySQL.AppendLine("LEFT JOIN Sa_Org_PersonInfo AS p ON p.PERSONCODE = d.userID ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_type_property AS tp ON tp.typeID = d.TypeID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND d.UnitCode = '" + strArray[13] + "' ");

                if ("0".Equals(sf))
                {
                    sbQuerySQL.AppendLine(" AND d.userID = '" + personCode + "' ");
                }
                if ("10".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + deptCode + "' ");
                    sbQuerySQL.AppendLine(GetLineMangerAllDeptCode(personCode, UnitCode, "d.departmentID"));
                }

                if ("20".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");

                }

                if ("30".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if ("100".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if ("200".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if ("300".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }
                if ("999".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }


                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND d.procurementType = '" + procurementType + "' ");
                }
                if (!string.IsNullOrEmpty(typeID))
                {
                    sbQuerySQL.AppendLine(" AND d.typeID = '" + typeID + "' ");
                }
                if (!string.IsNullOrEmpty(propertyNumber))
                {
                    sbQuerySQL.AppendLine(" AND d.propertyNumber = '" + propertyNumber + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND d.propertyName like '%" + propertyName + "%' ");
                }
                if (!string.IsNullOrEmpty(serialNumber))
                {
                    sbQuerySQL.AppendLine(" AND d.serialNumber = '" + serialNumber + "' ");
                }
                if (!string.IsNullOrEmpty(userID))
                {
                    sbQuerySQL.AppendLine(" AND d.userID = '" + userID + "' ");
                }
                if (!string.IsNullOrEmpty(state))
                {
                    if ("5".Equals(state))
                    {
                        sbQuerySQL.AppendLine(" AND d.state = '5' ");
                    }
                    else
                    {
                        sbQuerySQL.AppendLine(" AND d.state != '5' ");
                    }
                }
                if (!string.IsNullOrEmpty(sDate))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(d.Sys_InputDateTime, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY d.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion

             
                myLogT.WriteInfoToTxtFile("SysLog", "fyb20250702-1.txt", sbQuerySQL.ToString());


                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }
            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        //根据资产id查询转移记录
        public string GetTransferLogByDetailID(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_fixed_transfer_log"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string detailID = ""; //固资产ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            detailID = strArray[2];

            #region 生成统计总条数的sql语句
            StringBuilder totalSQL = new StringBuilder();
            totalSQL.AppendLine("SELECT COUNT(*) AS total FROM " + strDBTblName);
            totalSQL.AppendLine(" WHERE ");
            totalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            totalSQL.AppendLine(" AND detailID = '" + detailID + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, totalSQL.ToString());
            JObject jo = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                jo.Add("totalNum", 0);
                jo.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;
                #region 生成查询sql语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT logID, ransferorName, transferAt, shiftToName, reason, transferType, state FROM " + strDBTblName);
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND detailID = '" + detailID + "' ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                jo.Add("totalNum", oo["total"].Value<int>());
                jo.Add("list", JArray.Parse(list));
            }
            strRtData = jo.ToString();
            return strRtData;//返回结果
        }
        //根据资产id查询维修记录
        public string GetRepairByDetailID(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_fixed_repair_log"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string detailID = ""; //固资产ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            detailID = strArray[2];

            #region 生成统计总条数的sql语句
            StringBuilder totalSQL = new StringBuilder();
            totalSQL.AppendLine("SELECT COUNT(logID) FROM " + strDBTblName);
            totalSQL.AppendLine(" WHERE ");
            totalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            totalSQL.AppendLine(" AND detailID = '" + detailID + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, totalSQL.ToString());
            JObject jo = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                jo.Add("totalNum", 0);
                jo.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;
                #region 生成查询sql语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT logID, repairerName, repairTime, state, faultProblem, problemDescription FROM " + strDBTblName);
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND detailID = '" + detailID + "' ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion

                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

                jo.Add("totalNum", oo["total"].Value<int>());
                jo.Add("list", list);
            }
            strRtData = jo.ToString();
            return strRtData;//返回结果
        }
        //导出资产明细表 未实现
        public string ExportPpropertyDetail(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_property_detail"; //主表库名称
            //string procurementType = "1"; //采购类型 1 固定资产 2 非固定资产

            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //procurementType = strArray[0];

            //#region 生成查询sql语句
            //StringBuilder sbQuerySQL = new StringBuilder();

            //#endregion
            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            return strRtData;//返回结果
        }
        // ======================资产发放管理页面相关接口=====================
        // 分页获取资产发放数据列表
        public string GetFixedGrantList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_fixed_grant"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string procurementType = ""; //业务类型 1 固定资产 2 低值易耗品
            string propertyNumber = ""; //资产编号
            string propertyName = ""; //资产名称
            string applicantID = ""; //申请人(发放人)id
            string userID = ""; //接收人id
            string sTime = ""; //开始时间
            string eTime = ""; //结束时间

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            procurementType = strArray[2];
            propertyNumber = strArray[3];
            propertyName = strArray[4];
            applicantID = strArray[5];
            userID = strArray[6];
            sTime = strArray[7];
            eTime = strArray[8];

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(fg.grantID) AS total FROM " + strDBTblName + " AS fg");
            sbTotalSQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON fg.detailID = pd.detailID ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "fg.SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND pd.procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(propertyNumber))
            {
                sbTotalSQL.AppendLine(" AND pd.propertyNumber = '" + propertyNumber + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalSQL.AppendLine(" AND pd.propertyName like '%" + propertyName + "%' ");
            }
            if (!string.IsNullOrEmpty(applicantID))
            {
                sbTotalSQL.AppendLine(" AND fg.applicantID = '" + applicantID + "' ");
            }
            if (!string.IsNullOrEmpty(userID))
            {
                sbTotalSQL.AppendLine(" AND fg.userID = '" + userID + "' ");
            }
            if (!(string.IsNullOrEmpty(sTime) && string.IsNullOrEmpty(eTime)))
            {
                sbTotalSQL.AppendLine(" AND fg.CreatedAt bwteen '" + sTime + "' and '" + eTime + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT fg.grantID, pd.propertyNumber, pd.propertyName, pd.brands, pd.modelNumber, fg.userName, fg.state, fg.applicantName, fg.applicantTime FROM " + strDBTblName + " AS fg ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON fg.detailID = pd.detailID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "fg.SYS_CANCELDATETIME "));
                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND pd.procurementType = '" + procurementType + "' ");
                }
                if (!string.IsNullOrEmpty(propertyNumber))
                {
                    sbQuerySQL.AppendLine(" AND pd.propertyNumber = '" + propertyNumber + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND pd.propertyName like '%" + propertyName + "%' ");
                }
                if (!string.IsNullOrEmpty(applicantID))
                {
                    sbQuerySQL.AppendLine(" AND fg.applicantID = '" + applicantID + "' ");
                }
                if (!string.IsNullOrEmpty(userID))
                {
                    sbQuerySQL.AppendLine(" AND fg.userID = '" + userID + "' ");
                }
                if (!(string.IsNullOrEmpty(sTime) && string.IsNullOrEmpty(eTime)))
                {
                    sbQuerySQL.AppendLine(" AND fg.applicantTime bwteen '" + sTime + "' and '" + eTime + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY fg.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }
            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        // 导出发放管理列表数据
        public string ExportFixedGrantList(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_fixed_grant"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }
        //发放管理申请单打印 未实现
        public string GetGrantForNote(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_property_detail"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }

        // ======================报修管理页面相关接口=====================
        // 分页获取报修数据列表
        public string GetFixedRepairLogList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);


            //前端传回的数据
            //var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ jsonObj.propertyNumber}★${ jsonObj.propertyName}★${ jsonObj.repairerID}★${ jsonObj.sDate}★${ jsonObj.eDate}★${ ObjToStr(localStorage_getValue("UnitCode"))}`;
            //strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}★${ ObjToStr(localStorage_getValue("PersonCode"))}★${ ObjToStr(localStorage_getValue("DeptCode"))}`

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_fixed_repair_log"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string propertyNumber = ""; //资产编号
            string propertyName = ""; //资产名称
            string repairerID = ""; //报修人id
            string sDate = ""; //开始时间
            string eDate = ""; //结束时间
            string UnitCode = "";
            string RoleName = "";
            string PersonCode = "";
            string DeptCode = "";


            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            propertyNumber = strArray[2];
            propertyName = strArray[3];
            repairerID = strArray[4];
            sDate = strArray[5];
            eDate = strArray[6];
            UnitCode = strArray[7];
            RoleName = strArray[8];
            PersonCode = strArray[9];
            DeptCode = strArray[10];

            string sf = getPersonneInfo(RoleName);
            

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(frl.logID) AS total FROM " + strDBTblName + " AS frl ");
            sbTotalSQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON frl.detailID = pd.detailID ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "frl.SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND frl.UnitCode = '" + UnitCode + "' ");

            if (sf.Equals("0"))
            {
                sbTotalSQL.AppendLine(" AND frl.repairerID = '" + PersonCode + "' ");
            }

            if (sf.Equals("10"))
            {
                sbTotalSQL.AppendLine(" AND frl.repairerDepartmentID = '" + DeptCode + "' ");
            }

            if ("20".Equals(sf))
            {
                // sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");

            }

            if ("30".Equals(sf))
            {
                // sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }

            if ("100".Equals(sf))
            {
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }

            if ("200".Equals(sf))
            {
                // sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }

            if ("300".Equals(sf))
            {
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }
            if ("999".Equals(sf))
            {
                //sbTotalSQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
            }


            if (!string.IsNullOrEmpty(propertyNumber))
            {
                sbTotalSQL.AppendLine(" AND pd.propertyNumber = '" + propertyNumber + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalSQL.AppendLine(" AND pd.propertyName like '%" + propertyName + "%' ");
            }
            if (!string.IsNullOrEmpty(repairerID))
            {
                sbTotalSQL.AppendLine(" AND frl.repairerID = '" + repairerID + "' ");
            }
            if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE( frl.repairTime, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;

            clsRWFile myLogT = new clsRWFile(); //将待执行的SQL语句记录下来
            myLogT.WriteInfoToTxtFile("SysLog", "11.txt", sbTotalSQL.ToString());
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            } else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;
                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT frl.logID, pd.propertyNumber, pd.propertyName, pd.brands, pd.modelNumber, pd.serialNumber,frl.ZMPicture, frl.faultProblem, frl.problemDescription, frl.repairerName, frl.state, frl.repairTime,frl.repairSuggestions FROM " + strDBTblName + " AS frl ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON frl.detailID = pd.detailID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "frl.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND frl.UnitCode = '" + UnitCode + "' ");

                if (sf.Equals("0"))
                {
                    sbQuerySQL.AppendLine(" AND frl.repairerID = '" + PersonCode + "' ");
                }

                if (sf.Equals("10"))
                {
                    sbQuerySQL.AppendLine(" AND frl.repairerDepartmentID = '" + DeptCode + "' ");
                }

                if ("20".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");

                }

                if ("30".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if ("100".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if ("200".Equals(sf))
                {
                    // sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if ("300".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }
                if ("999".Equals(sf))
                {
                    //sbQuerySQL.AppendLine(" AND d.departmentID = '" + strArray[11] + "' ");
                }

                if (!string.IsNullOrEmpty(propertyNumber))
                {
                    sbQuerySQL.AppendLine(" AND pd.propertyNumber = '" + propertyNumber + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND pd.propertyName like '%" + propertyName + "%' ");
                }
                if (!string.IsNullOrEmpty(repairerID))
                {
                    sbQuerySQL.AppendLine(" AND frl.repairerID = '" + repairerID + "' ");
                }
                if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE( frl.repairTime, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY frl.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                myLogT.WriteInfoToTxtFile("SysLog", "11.txt", sbQuerySQL.ToString());
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }
            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        //导出报修数据
        public string ExportFixedRepairLogList(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_fixed_repair_log"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }

        // ======================报废管理页面相关接口=====================
        // 分页获取报废总表
        public string GetYaraScrapSetList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_scrap_set"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数号
            string state = ""; //状态
            string userID = ""; //申请人id
            string procurementType = "";
            string sType = "";
            string UnitCode = "";
            string RoleName = "";
            string DeptCode = "";
            string scrapDH = string.Empty;


          //  var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ jsonObj.state}★${ jsonObj.userID}★${ jsonObj.procurementType}★${ jsonObj.sType}★${ ObjToStr(localStorage_getValue("UnitCode"))}`;
           // strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}★${ ObjToStr(localStorage_getValue("DeptCode"))}★${ jsonObj.scrapDH}`

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            state = strArray[2];
            userID = strArray[3];
            procurementType = strArray[4];
            sType = strArray[5];
            UnitCode = strArray[6];
            RoleName = strArray[7];
            DeptCode = strArray[8];
            scrapDH = strArray[9];


            string sf = getPersonneInfo(RoleName);

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(iID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");

            if (sf.Equals("0"))
            {
                sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            }

            if (sf.Equals("10"))
            {
                sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            if (sf.Equals("20"))
            {
               // sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            }

            if (sf.Equals("30"))
            {
                //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            if (sf.Equals("100"))
            {
                //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            if (sf.Equals("200"))
            {
                //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            if (sf.Equals("300"))
            {
                //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            if (sf.Equals("999"))
            {
                //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            if (!string.IsNullOrEmpty(scrapDH))
            {
                sbTotalSQL.AppendLine(" AND scrapDH = '" + scrapDH + "' ");
            }

            if (!string.IsNullOrEmpty(state))
            {
                sbTotalSQL.AppendLine(" AND state = '" + state + "' ");
            }
            //if (!string.IsNullOrEmpty(userID))
            //{
            //    sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            //}
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(sType))
            {
                sbTotalSQL.AppendLine(" AND sType = '" + sType + "' ");
            }

            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
                                                      //获取总条数
            clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "fyb1212.txt", sbTotalSQL.ToString());
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT s.iID,s.procurementType,s.spuserID,s.scrapDH,s.scrapAt,s.scrapNum,s.userID,s.userName,s.departmentID,s.department,s.scrapSum,s.state,s.SYS_RECORDID AS strRecordID,s.sType,s.Dstate,s.Dinfo,s.isCompensation,s.CompensationPrice,s.RecyclingUnit,s.modelDescribe,p.WorkNumber FROM " + strDBTblName + " AS s ");
                sbQuerySQL.AppendLine("LEFT JOIN Sa_Org_PersonInfo AS p ON p.PERSONCODE = s.userID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "s.SYS_CANCELDATETIME "));
                sbTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");

                if (sf.Equals("0"))
                {
                    sbQuerySQL.AppendLine(" AND userID = '" + userID + "' ");
                }

                if (sf.Equals("10"))
                {
                    sbQuerySQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (sf.Equals("20"))
                {
                    // sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
                }

                if (sf.Equals("30"))
                {
                    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (sf.Equals("100"))
                {
                    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (sf.Equals("200"))
                {
                    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (sf.Equals("300"))
                {
                    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (sf.Equals("999"))
                {
                    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (!string.IsNullOrEmpty(scrapDH))
                {
                    sbQuerySQL.AppendLine(" AND scrapDH = '" + scrapDH + "' ");
                }
                if (!string.IsNullOrEmpty(sType))
                {
                    sbQuerySQL.AppendLine(" AND sType = '" + sType + "' ");
                }
                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY s.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //myLog.WriteInfoToTxtFile("SysLog", "fyb1212.txt", sbQuerySQL.ToString());
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }

            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }

        /// <summary>
        /// 代办中的审批报废列表
        /// </summary>
        /// <param name="strB64RequestData"></param>
        /// <returns></returns>
        public string GetSPYaraScrapSetList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_scrap_set"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数号
            string state = ""; //状态
            string userID = ""; //申请人id
            string procurementType = "";
            string sType = "";
            string UnitCode = "";
            string PersonCode = "";



            //`${jsonObj.pageNum}★${jsonObj.pageSize}★${jsonObj.state}★${jsonObj.userID}★${jsonObj.procurementType}★${jsonObj.sType}★${ObjToStr(localStorage_getValue("UnitCode"))}★${ObjToStr(localStorage_getValue("PersonCode"))}`;  
            //${jsonObj.pageNum}★${jsonObj.pageSize}★${jsonObj.state}★$ jsonObj.userID}★${ jsonObj.procurementType}★${ jsonObj.sType}★${ ObjToStr(localStorage_getValue("UnitCode"))}★${ ObjToStr(localStorage_getValue("PersonCode"))}`;

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            state = strArray[2];
            userID = strArray[3];
            procurementType = strArray[4];
            sType = strArray[5];  //内部还是外部标志  内部：1   外部：2  
            UnitCode = strArray[6];
            PersonCode = strArray[7];
     


           // string sf = getPersonneInfo(RoleName);

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(iID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");

            if (!string.IsNullOrEmpty(PersonCode))
            {
                sbTotalSQL.AppendLine(" AND modelDescribe like '%" + PersonCode + "%' ");
            }

            //if (sf.Equals("0"))
            //{
            //    sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            //}

            //if (sf.Equals("10"))
            //{
            //    sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("20"))
            //{
            //    // sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            //}

            //if (sf.Equals("30"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("100"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("200"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("300"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("999"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (!string.IsNullOrEmpty(scrapDH))
            //{
            //    sbTotalSQL.AppendLine(" AND scrapDH = '" + scrapDH + "' ");
            //}

            if (!string.IsNullOrEmpty(state))
            {
                sbTotalSQL.AppendLine(" AND state = '" + state + "' ");
            }
            //if (!string.IsNullOrEmpty(userID))
            //{
            //    sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            //}
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(sType))
            {
                sbTotalSQL.AppendLine(" AND sType = '" + sType + "' ");
            }

            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
                                                      //获取总条数
            clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            myLog.WriteInfoToTxtFile("SysLog", "fyb1212.txt", sbTotalSQL.ToString());
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT s.iID,s.procurementType,s.spuserID,s.scrapDH,s.scrapAt,s.scrapNum,s.userID,s.userName,s.departmentID,s.department,s.scrapSum,s.state,s.SYS_RECORDID AS strRecordID,s.sType,s.Dstate,s.Dinfo,s.isCompensation,s.CompensationPrice,s.RecyclingUnit,s.modelDescribe,p.WorkNumber FROM " + strDBTblName + " AS s ");
                sbQuerySQL.AppendLine("LEFT JOIN Sa_Org_PersonInfo AS p ON p.PERSONCODE = s.userID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "s.SYS_CANCELDATETIME "));
                sbTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");

                //if (sf.Equals("0"))
                //{
                //    sbQuerySQL.AppendLine(" AND userID = '" + userID + "' ");
                //}

                //if (sf.Equals("10"))
                //{
                //    sbQuerySQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                //}

                //if (sf.Equals("20"))
                //{
                //    // sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
                //}

                //if (sf.Equals("30"))
                //{
                //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                //}

                //if (sf.Equals("100"))
                //{
                //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                //}

                //if (sf.Equals("200"))
                //{
                //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                //}

                //if (sf.Equals("300"))
                //{
                //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                //}

                //if (sf.Equals("999"))
                //{
                //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                //}

                //if (!string.IsNullOrEmpty(scrapDH))
                //{
                //    sbQuerySQL.AppendLine(" AND scrapDH = '" + scrapDH + "' ");
                //}

                if (!string.IsNullOrEmpty(PersonCode))
                {
                    sbQuerySQL.AppendLine(" AND modelDescribe like '%" + PersonCode + "%' ");
                }

                if (!string.IsNullOrEmpty(sType))
                {
                    sbQuerySQL.AppendLine(" AND sType = '" + sType + "' ");
                }
                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY s.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                myLog.WriteInfoToTxtFile("SysLog", "fyb1212.txt", sbQuerySQL.ToString());
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }

            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }

        // 分页获取报废明细数据列表
        public string GetYaraScrapList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_scrap"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string propertyNumber = ""; //资产编号
            string propertyName = ""; //资产名称
            string userID = ""; //报废申请人id
            string sDate = ""; //开始时间
            string eDate = ""; //结束时间
            string scrapSetID = "";
            string UnitCode = "";
            string RoleName = "";
            string PersonCode = "";
            string DeptCode = "";

            string sf = "";

            //这些参数用★分隔开，客户端与服务器端要一致
            //var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ jsonObj.propertyNumber}★${ jsonObj.propertyName}★${ jsonObj.userID}★${ jsonObj.sDate}★${ jsonObj.eDate}★${ jsonObj.setID}★${ ObjToStr(localStorage_getValue("UnitCode"))}`;
            // strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}★${ObjToStr(localStorage_getValue("PersonCode"))}★${ObjToStr(localStorage_getValue("DeptCode"))}`

            //     var strRequestData = `${jsonObj.pageNum}★${jsonObj.pageSize}★${jsonObj.propertyNumber}★${jsonObj.propertyName}★${jsonObj.userID}★${jsonObj.sDate}★${jsonObj.eDate}★${jsonObj.setID}★${ObjToStr(localStorage_getValue("UnitCode"))}`;  
           // strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}★${ ObjToStr(localStorage_getValue("PersonCode"))}★${ ObjToStr(localStorage_getValue("DeptCode"))}`
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            propertyNumber = strArray[2];
            propertyName = strArray[3];
            userID = strArray[4];
            sDate = strArray[5];
            eDate = strArray[6];
            scrapSetID = strArray[7];
            UnitCode = strArray[8];
            RoleName = strArray[9];
            PersonCode = strArray[10];
            DeptCode = strArray[11];

            sf = getPersonneInfo(RoleName);

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(scrapID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");

            if (sf.Equals("0"))
            {
                sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            }

            if (sf.Equals("10"))
            {
                sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            }

            //if (sf.Equals("20"))
            //{
            //    // sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            //}

            //if (sf.Equals("30"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("100"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("200"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("300"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (sf.Equals("999"))
            //{
            //    //sbTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
            //}

            //if (!string.IsNullOrEmpty(scrapDH))
            //{
            //    sbQuerySQL.AppendLine(" AND scrapDH = '" + scrapDH + "' ");
            //}

            if (!string.IsNullOrEmpty(propertyNumber))
            {
                sbTotalSQL.AppendLine(" AND propertyNumber = '" + propertyNumber + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalSQL.AppendLine(" AND propertyName like '%" + propertyName + "%' ");
            }
            //if (!string.IsNullOrEmpty(userID))
            //{
            //    sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            //}
            if (!string.IsNullOrEmpty(scrapSetID))
            {
                sbTotalSQL.AppendLine(" AND scrapSetID = '" + scrapSetID + "' ");
            }
            if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE( applicationAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT   p.detailID,s.PersonName,s.faultProblem,p.propertyNumber,p.propertyName,p.brands,p.modelNumber,p.serialNumber,s.scrapID,s.propertyID,s.sType,s.isCompensation,s.CompensationPrice,p.userName,s.problemDescription ,s.yuanzhi,s.NumberS,s.luruDate,s.clDate,s.sjsyM,s.sjzjM,s.pclz,s.CreatedAt,s.RecyclingPrice,s.Sys_InputDateTime   FROM  " + strDBTblName + "  as s  ");
                sbQuerySQL.AppendLine(" LEFT JOIN  yara_property_detail p  on s.propertyID = p.detailID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "s.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND p.UnitCode = '" + UnitCode + "' ");


                if (sf.Equals("0"))
                {
                    sbQuerySQL.AppendLine(" AND userID = '" + userID + "' ");
                }

                if (sf.Equals("10"))
                {
                    sbQuerySQL.AppendLine(" AND departmentID = '" + DeptCode + "' ");
                }

                if (!string.IsNullOrEmpty(propertyNumber))
                {
                    sbQuerySQL.AppendLine(" AND s.propertyNumber = '" + propertyNumber + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND s.propertyName like '%" + propertyName + "%' ");
                }
                //if (!string.IsNullOrEmpty(userID))
                //{
                //    sbQuerySQL.AppendLine(" AND s.userID = '" + userID + "' ");
                //}
                if (!string.IsNullOrEmpty(scrapSetID))
                {
                    sbQuerySQL.AppendLine(" AND s.scrapSetID = '" + scrapSetID + "' ");
                }
                if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE( s.applicationAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY s.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion

                //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
                //myLog.WriteInfoToTxtFile("SysLog", "yangqi_sql11.txt", sbQuerySQL.ToString());

                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }

            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        //导出报废数据列表
        public string ExportYaraScrapList(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_scrap"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }

        // ======================转移管理页面相关接口=====================
        // 分页获取转移总表
        public string GetYaraTransferSetList(string strB64RequestData)   //不在使用 20250624 fyb
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);


            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_transfer_set"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数号
            string state = ""; //状态
            string userID = ""; //申请人id
            string procurementType = "";
            string sDate = "";//最后操作开始日期
            string eDate = "";//最后操作结束日期
            string DeptCode = "";
            string PersonCode = "";
            string UnitCode = "";
            string RoleName = "";

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            //var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ jsonObj.state}★${ jsonObj.userID}★${ jsonObj.procurementType}★${ jsonObj.sDate}
            //★${ jsonObj.eDate}★${ ObjToStr(localStorage_getValue("DeptCode"))}★${ ObjToStr(localStorage_getValue("PersonCode"))}★${ ObjToStr(localStorage_getValue("UnitCode"))}`;
            //strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}`

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            state = strArray[2];
            userID = strArray[3];
            procurementType = strArray[4];
            sDate = strArray[5];
            eDate = strArray[6];
            DeptCode = strArray[7];
            PersonCode= strArray[8];
            UnitCode= strArray[9];
            RoleName = strArray[10];

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(iID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");
            if (!string.IsNullOrEmpty(PersonCode))
            {
                sbTotalSQL.AppendLine(" AND modelDescribe like '%" + PersonCode + "%' ");
            }


            if (!string.IsNullOrEmpty(state))
            {
                //sbTotalSQL.AppendLine(" AND state = '" + state + "' ");
            }
            //if (!string.IsNullOrEmpty(userID))
            //{
            //    sbTotalSQL.AppendLine(" AND userID = '" + userID + "' "); 
            //}
            //if (!string.IsNullOrEmpty(procurementType))
            //{
            //    sbTotalSQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            //}
            if (!string.IsNullOrEmpty(sDate))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE(Sys_InputDateTime, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }

            #endregion

            sbTotalSQL.AppendLine("ORDER BY Sys_InputDateTime DESC ");
            clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            myLog.WriteInfoToTxtFile("SysLog", "yangqi_count.txt", sbTotalSQL.ToString());




            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT iID,procurementType,scrapDH,scrapAt,scrapNum,userID,userName,departmentID,spuserID,department,scrapSum,state,SYS_RECORDID AS strRecordID,Dstate,Dinfo,jsuserID,jsuserName,jsdepartmentID,jsdepartment,modelDescribe FROM " + strDBTblName + " ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");

                if (!string.IsNullOrEmpty(PersonCode))
                {
                    sbQuerySQL.AppendLine(" AND modelDescribe like '%" + PersonCode + "%' ");
                }



                if (!string.IsNullOrEmpty(state))
                {
                    //sbQuerySQL.AppendLine(" AND state = '" + state + "' ");
                }
                //if (!string.IsNullOrEmpty(userID))
                //{
                //    sbQuerySQL.AppendLine(" AND userID = '" + userID + "' ");
                //}
                //if (!string.IsNullOrEmpty(procurementType))
                //{
                //    sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
                //}
                if (!string.IsNullOrEmpty(sDate))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(Sys_InputDateTime, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion


                myLog.WriteInfoToTxtFile("SysLog", "yangqi_list.txt", sbQuerySQL.ToString());

                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                JArray arr = JArray.Parse(list);

              //  myLog.WriteInfoToTxtFile("SysLog", "yangqi_list_arr.txt", list);

                //foreach (var item in arr)
                //{
                //    string sql = "select detailID,detailName from yara_fixed_transfer_log where scrapSetID = '"+ (string)item["iID"] +"' "+ "AND "+ clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME");
                //    string cList = myDB.YookingExecuteJson(strDBGroup, sql);


                //    if (!"{\"result\":\"yooking null\"}".Equals(str))
                //    {
                //        item["family"] = JArray.Parse(cList);
                //    }

                   
                //}
                ob.Add("list", arr);
            }

            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        // 分页获取转移数据列表
        public string GetFixedTransferLogList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //var strRequestData = `${jsonObj.pageNum}★${jsonObj.pageSize}★${jsonObj.procurementType}★${jsonObj.propertyNumber}★${jsonObj.propertyName}★${jsonObj.ransferorID}★${jsonObj.shiftToID}★${jsonObj.sDate}
            //★${jsonObj.eDate}
            //★${jsonObj.scrapSetID}★${jsonObj.state}★${ObjToStr(localStorage_getValue("DeptCode"))}★${ObjToStr(localStorage_getValue("PersonCode"))}★${ObjToStr(localStorage_getValue("UnitCode"))}`;  
            //strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}`
            //

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_fixed_transfer_log"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string procurementType = ""; //业务类型 1 固定资产 2 低值易耗品
            string propertyNumber = ""; //资产编号
            string propertyName = ""; //资产名称
            string ransferorID = ""; //转出人员id
            string shiftToID = ""; //接收人员id
            string sDate = ""; //开始时间
            string eDate = ""; //结束时间
            string scrapSetID = string.Empty;
            string state = string.Empty;
            string DeptCode = string.Empty;
            string PersonCode = string.Empty;
            string UnitCode = string.Empty;
            string RoleName= string.Empty; 

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            procurementType = strArray[2];
            propertyNumber = strArray[3];
            propertyName = strArray[4];
            ransferorID = strArray[5];
            shiftToID = strArray[6];
            sDate = strArray[7];
            eDate = strArray[8];
            scrapSetID= strArray[9];
            state= strArray[10];    
            DeptCode = strArray[11];
            PersonCode= strArray[12]; 
            UnitCode= strArray[13];
            RoleName= strArray[14];

            string sf = getPersonneInfo(RoleName);

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(tra.logID) AS total FROM " + strDBTblName + " AS tra ");
            sbTotalSQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON tra.detailID = pd.detailID ");
            sbTotalSQL.AppendLine("LEFT JOIN yara_transfer_set AS yts ON tra.scrapSetID = yts.iID ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "tra.SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND tra.UnitCode = '" + UnitCode + "' ");

            if (sf.Equals("0"))
            {
                sbTotalSQL.AppendLine(" AND ( tra.ransferorID = '" + PersonCode + "' ");
                sbTotalSQL.AppendLine("or tra.shiftToID = '" + PersonCode + "') ");
            }
            if (sf.Equals("10"))
            {
                sbTotalSQL.AppendLine(" AND (tra.ransferorDepartmentID  = '" + DeptCode + "' ");
                sbTotalSQL.AppendLine("or tra.shiftToDepartmentID = '" + DeptCode + "') ");
            }
            if (sf.Equals("20"))
            {

            }
            if (sf.Equals("30"))
            {

            }
            if (sf.Equals("100"))
            {

            }
            if (sf.Equals("200"))
            {

            }
            if (sf.Equals("300"))
            {

            }
            if (sf.Equals("999"))
            {

            }
          

            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND pd.procurementType = '" + procurementType + "' ");
            }
            if (!string.IsNullOrEmpty(propertyNumber))
            {
                sbTotalSQL.AppendLine(" AND pd.propertyNumber = '" + propertyNumber + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalSQL.AppendLine(" AND pd.propertyName like '%" + propertyName + "%' ");
            }


            if (!string.IsNullOrEmpty(ransferorID))
            {
                //sbQuerySQL.AppendLine(" AND tra.ransferorID = '" + ransferorID + "' ");
                sbTotalSQL.AppendLine(" AND (tra.ransferorID = '" + ransferorID + "' ");
                sbTotalSQL.AppendLine("or tra.shiftToID = '" + ransferorID + "') ");
            }
            if (!string.IsNullOrEmpty(shiftToID))
            {
                sbTotalSQL.AppendLine(" AND (tra.ransferorID = '" + shiftToID + "' ");
                sbTotalSQL.AppendLine("or tra.shiftToID = '" + shiftToID + "') ");
            }
          
            if (!string.IsNullOrEmpty(scrapSetID))
            {
                sbTotalSQL.AppendLine(" AND tra.scrapSetID = '" + scrapSetID + "' ");
            }
            if (!string.IsNullOrEmpty(state))
            {
                sbTotalSQL.AppendLine(" AND yts.state = '" + state + "' ");
            }
            if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE( tra.transferAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }


            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT yts.Dstate,yts.QSDate, tra.logID,tra.detailID, tra.shiftToID, tra.shiftToName, tra.shiftToDepartmentID, tra.shiftToDepartment, pd.propertyNumber, pd.propertyName, pd.brands, pd.modelNumber, pd.serialNumber, tra.ransferorName, tra.transferAt, tra.reason, tra.state, tra.CreatedAt,yts.scrapDH,yts.state as totalState,yts.iID,yts.modelDescribe FROM " + strDBTblName + " AS tra ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON tra.detailID = pd.detailID ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_transfer_set AS yts ON tra.scrapSetID = yts.iID ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "tra.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND tra.UnitCode = '" + UnitCode + "' ");

                if (sf.Equals("0"))
                {
                    sbQuerySQL.AppendLine(" AND (tra.ransferorID = '" + PersonCode + "' ");
                    sbQuerySQL.AppendLine("or tra.shiftToID = '" + PersonCode + "') ");
                }
                if (sf.Equals("10"))
                {
                    sbQuerySQL.AppendLine(" AND (tra.ransferorDepartmentID  = '" + DeptCode + "' ");
                    sbQuerySQL.AppendLine("or tra.shiftToDepartmentID = '" + DeptCode + "') ");
                }
                if (sf.Equals("20"))
                {

                }
                if (sf.Equals("30"))
                {

                }
                if (sf.Equals("100"))
                {

                }
                if (sf.Equals("200"))
                {

                }
                if (sf.Equals("300"))
                {

                }
                if (sf.Equals("999"))
                {

                }


                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND pd.procurementType = '" + procurementType + "' ");
                }
                if (!string.IsNullOrEmpty(propertyNumber))
                {
                    sbQuerySQL.AppendLine(" AND pd.propertyNumber = '" + propertyNumber + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND pd.propertyName like '%" + propertyName + "%' ");
                }

                if (!string.IsNullOrEmpty(ransferorID))
                {
                    //sbQuerySQL.AppendLine(" AND tra.ransferorID = '" + ransferorID + "' ");
                    sbQuerySQL.AppendLine(" AND (tra.ransferorID = '" + ransferorID + "' ");
                    sbQuerySQL.AppendLine("or tra.shiftToID = '" + ransferorID + "') ");
                }
                if (!string.IsNullOrEmpty(shiftToID))
                {
                    sbQuerySQL.AppendLine(" AND (tra.ransferorID = '" + shiftToID + "' ");
                    sbQuerySQL.AppendLine("or tra.shiftToID = '" + shiftToID + "') ");
                }


                if (!string.IsNullOrEmpty(scrapSetID))
                {
                    sbQuerySQL.AppendLine(" AND tra.scrapSetID = '" + scrapSetID + "' ");
                }
                if (!string.IsNullOrEmpty(state))
                {
                    sbQuerySQL.AppendLine(" AND yts.state = '" + state + "' ");
                }
                if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE( tra.transferAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY tra.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }
            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        //导出转移数据列表 未实现
        public string ExportFixedTransferLogList(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_fixed_transfer_log"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }
        // 获取转移申请单  未实现
        public string GetFixedTransferLogApply(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_fixed_transfer_log"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }
        // 获取转移签收单 未实现
        public string GetFixedTransferLogReceipt(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_fixed_transfer_log"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }

        // ======================消息列表页面接口=====================
        // 分页获取消息列表数据
        public string GetYaraMessageList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_message"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string msgTitle = ""; //消息标题
            string userID = ""; //接收人员id
            string sDate = ""; //开始时间
            string eDate = ""; //结束时间

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            msgTitle = strArray[2];
            userID = strArray[3];
            sDate = strArray[4];
            eDate = strArray[5];

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(*) AS total FROM " + strDBTblName);
            sbTotalSQL.AppendLine(" WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(msgTitle))
            {
                sbTotalSQL.AppendLine(" AND msgTitle = '" + msgTitle + "' ");
            }
            if (!string.IsNullOrEmpty(userID))
            {
                sbTotalSQL.AppendLine(" AND userID = '" + userID + "' ");
            }
            if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE(CreatedAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }

            sbTotalSQL.AppendLine("ORDER BY CreatedAt DESC ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT msgID, msgType, msgTitle, sendStatusWx, sendStatusYx, userName, isView, CreatedAt FROM " + strDBTblName);
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                if (!string.IsNullOrEmpty(msgTitle))
                {
                    sbQuerySQL.AppendLine(" AND msgTitle = '" + msgTitle + "' ");
                }
                if (!string.IsNullOrEmpty(userID))
                {
                    sbQuerySQL.AppendLine(" AND userID = '" + userID + "' ");
                }
                if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(CreatedAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }

            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }
        //导出消息列表数据 未实现
        public string ExportYaraMessageList(string strB64RequestData)
        {
            string strRtData = "no data";

            ////先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //string strDBGroup = "Data";   //主表数据库分组名
            //string strDBTblName = "yara_message"; //主表库名称
            //string buyID = ""; //采购单ID
            ////这些参数用★分隔开，客户端与服务器端要一致
            //string[] strArray = strRequestData.Split('★');

            //buyID = strArray[0];
            //StringBuilder sbQuerySQL = new StringBuilder();

            //clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            ////获取数据
            //strRtData = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            return strRtData; //数据库查询结果
        }

        //========================= 盘点设置 =============
        // 分页获取盘点设置列表数据
        public string GetYaraInventorySetList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_inventory_set"; //主表库名称
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string procurementType = ""; //业务类型 1 固资产 2 低值易耗品

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            procurementType = strArray[2];

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(iID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine(" WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND UnitCode = '" + strArray[3] + "' ");
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT  InventoryNumber, iID, procurementType,startAt,end,Inventoried,state,SYS_RECORDID AS strRecordID  FROM " + strDBTblName + " ");
                sbQuerySQL.AppendLine("WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND UnitCode = '" + strArray[3] + "' ");
                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                JArray pdList = JArray.Parse(list);

               
                foreach (JObject item in pdList)
                {
                    StringBuilder gdSQL = new StringBuilder();
                    gdSQL.AppendLine("SELECT count(*) AS total FROM  yara_property_detail ");
                    gdSQL.AppendLine(" WHERE ");
                    gdSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                    gdSQL.AppendLine(" AND DATE(STR_TO_DATE(CreatedAt, '%Y-%m-%d')) BETWEEN '" + item["startAt"] + "' AND '" + item["end"] + "' ");
                    gdSQL.AppendLine(" AND procurementType = '1' ");

                    string gdList = myDB.YookingExecuteJson(strDBGroup, gdSQL.ToString());
                    JObject gd = JArray.Parse(gdList)[0] as JObject;
                    StringBuilder dzSQL = new StringBuilder();
                    dzSQL.AppendLine("SELECT count(*) AS total FROM  yara_property_detail ");
                    dzSQL.AppendLine(" WHERE ");
                    dzSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
                    dzSQL.AppendLine(" AND DATE(STR_TO_DATE(CreatedAt, '%Y-%m-%d')) BETWEEN '" + item["startAt"] + "' AND '" + item["end"] + "' ");
                    dzSQL.AppendLine(" AND procurementType = '2' ");

                    string dzList = myDB.YookingExecuteJson(strDBGroup, dzSQL.ToString());
                    JObject dz = JArray.Parse(dzList)[0] as JObject;
                    if (item["procurementType"].ToString().Equals("1"))
                    {
                        item.Add("NotInventoried", gd["total"].Value<int>() - item["Inventoried"].Value<int>());
                    }
                    else
                    {
                        item.Add("NotInventoried", dz["total"].Value<int>() - item["Inventoried"].Value<int>());
                    }
                }
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", pdList);
            }
            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }

        // 立即执行
        public string ZhiXingYaraInventorySet(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_inventory_info"; //主表库名称
            string strKeyColSet = "inventoryID";   //需要判断是否重值的字段名，支持可以多个字段
            string iID = "";
            string procurementType = "";
            string startAt = "";
            string end = "";
            string userName = "";
            string UnitCode = "";
            string InventoryNumber = "";


            // strRequestData = `${jsonObj.iID}★${jsonObj.procurementType}★${jsonObj.startAt}★${jsonObj.end}★${userName}
            // ★${ObjToStr(localStorage_getValue("UnitCode"))}★${jsonObj.InventoryNumber}`;
            //这些参数用★分隔开，客户端与服务器端要一致 0盘点配置id★1资产类型★2开始日期★3结束日期★4用户名
            string[] strArray = strRequestData.Split('★');
            iID= strArray[0];
            procurementType= strArray[1];
            startAt= strArray[2];
            end= strArray[3];
            userName= strArray[4];
            UnitCode = strArray[5];
            InventoryNumber = strArray[6];


            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT * FROM  yara_property_detail ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            sbQuerySQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");
            sbQuerySQL.AppendLine(" AND state <> '5' ");
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取需要插入的数据列表
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            JArray arr = JArray.Parse(list);
            JArray strJsonArray = new JArray();
            foreach (JObject obj in arr)
            {
                JObject o = new JObject();
                o.Add("UnitCode", UnitCode);
                o.Add("inventoryID", Guid.NewGuid().ToString());
                o.Add("setID", iID);
                o.Add("startAt", startAt);
                o.Add("end", end);
                o.Add("userID", obj["userID"]);
                o.Add("userName", obj["userName"]);
                o.Add("inventoryAt", DateTime.Now.ToString("yyyy-MM-dd"));
                o.Add("propertyID", obj["detailID"]);
                o.Add("DepartmentCode", obj["DepartmentID"]);                
                o.Add("propertyNumber", obj["propertyNumber"]);
                o.Add("propertyName", obj["propertyName"]);
                o.Add("brand", obj["brands"]);
                o.Add("modelNumber", obj["modelNumber"]);
                o.Add("serialNumber", obj["serialNumber"]);
                o.Add("state", "0");
                o.Add("CreatedAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                o.Add("InventoryNumber", InventoryNumber);
                o.Add("receiptTime", obj["receiptTime"]); //领用时间 fyb
                o.Add("confirmTime", "");  //资产确认时间，盘点时间 fyb
                strJsonArray.Add(o);
            }
            DataSet dsData = clsJConvert.JArryToDataSet(strJsonArray.ToString()); //将Json数组转成DataSet

            clsWriteDB myWrite = new clsWriteDB(); //先判断数据是否存在，根据判断结果自动执行insert或者update
            strRtData = myWrite.WriteDBNormal_UseSYSCol(strDBGroup, strDBTblName, strKeyColSet, strArray[4], dsData);

            return strRtData; //数据库操作的最终结果
        }

        // ======================盘点管理页面接口=====================
        // 分页获取盘点管理列表数据
        public string GetYaraInventoryInfoList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);


            //
            //var strRequestData = `${ jsonObj.pageNum}★${ jsonObj.pageSize}★${ jsonObj.procurementType}★${ jsonObj.propertyNumber}★${ jsonObj.propertyName}★${ jsonObj.userName}★${ jsonObj.sDate}
            //★${ jsonObj.eDate}★${ jsonObj.setID}★${ jsonObj.state}★${ ObjToStr(localStorage_getValue("UnitCode"))}★${ jsonObj.InventoryNumber}`;
            //strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}★${ObjToStr(localStorage_getValue("DeptCode"))★${ObjToStr(localStorage_getValue("PersonCode"))}`}`
            //
            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_inventory_info"; //主表库名称
            //string lastPDNumberByType = "";
            int pageNum = 1;//页数
            int pageSize = 10;//每页条数
            string procurementType = ""; //业务类型 1 固资产 2 低值易耗品
            string propertyNumber = ""; //资产编号
            string propertyName = "";//资产名称
            string userName = ""; //盘点人姓名
            string sDate = ""; //开始时间
            string eDate = ""; //结束时间
            string setID = "";
            string state = "";
            string UnitCode = "";
            string InventoryNumber = "";
            string RoleName = "";
            string DeptCode = "";
            string userID = "";


            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            pageNum = int.Parse(strArray[0]);
            pageSize = int.Parse(strArray[1]);
            procurementType = strArray[2];
            propertyNumber = strArray[3];
            propertyName = strArray[4];
            userName = strArray[5];
            sDate = strArray[6];
            eDate = strArray[7];
            setID = strArray[8];
            state = strArray[9];
            UnitCode  = strArray[10];
            InventoryNumber = strArray[11];
            RoleName = strArray[12];
            DeptCode = strArray[13];    
            userID = strArray[14];   ///前台传回★${ObjToStr(localStorage_getValue("PersonCode"))}`

            //lastPDNumberByType = GetLastPDNumber(procurementType, UnitCode);

            string sf = getPersonneInfo(RoleName);

            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(ii.inventoryID) AS total FROM " + strDBTblName + " AS ii ");
            sbTotalSQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON ii.propertyNumber = pd.propertyNumber ");
            sbTotalSQL.AppendLine("LEFT JOIN yara_type_property AS tp ON pd.TypeID = tp.typeID ");
            sbTotalSQL.AppendLine(" WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "ii.SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND ii.UnitCode = '" + UnitCode + "' ");

            if (sf.Equals("0"))
            {
                sbTotalSQL.AppendLine(" AND ii.userID = '" + userID + "' ");
            }

            if (sf.Equals("10"))
            {

               sbTotalSQL.AppendLine(" AND ii.DepartmentCode = '" + DeptCode + "' ");
            }

            if (sf.Equals("20"))
            {
                //  sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }
            if (sf.Equals("30"))
            {
                //  sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }
            if (sf.Equals("100"))
            {
                //  sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }

            if (sf.Equals("200"))
            {
                //  sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }
            if (sf.Equals("300"))
            {
                //  sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }

            if (sf.Equals("999"))
            {
                //  sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }



            if (!string.IsNullOrEmpty(InventoryNumber))  //根据InventoryNumber
            {
                sbTotalSQL.AppendLine(" AND ii.InventoryNumber = '" + InventoryNumber + "' ");
            }
          

            if (!string.IsNullOrEmpty(setID))
            {
                sbTotalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
            }
            if (!string.IsNullOrEmpty(state))
            {
                sbTotalSQL.AppendLine(" AND ii.state = '" + state + "' ");
            }
            if (!string.IsNullOrEmpty(procurementType))
            {
                sbTotalSQL.AppendLine(" AND tp.procurementType = '" + procurementType + "' ");
            }

            if (!string.IsNullOrEmpty(propertyNumber))
            {
                sbTotalSQL.AppendLine(" AND ii.propertyNumber = '" + propertyNumber + "' ");
            }
            if (!string.IsNullOrEmpty(propertyName))
            {
                sbTotalSQL.AppendLine(" AND ii.propertyName like '%" + propertyName + "%' ");
            }
            if (!string.IsNullOrEmpty(userName))
            {
                sbTotalSQL.AppendLine(" AND ii.userName = '" + userName + "' ");
            }
            
            if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
            {
                sbTotalSQL.AppendLine(" AND DATE(STR_TO_DATE(ii.inventoryAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject ob = new JObject();
            JObject oo = JArray.Parse(str)[0] as JObject;
            if ("0".Equals(oo["total"].ToString()))
            {
                ob.Add("totalNum", 0);
                ob.Add("list", new JArray());
            }
            else
            {
                //计算每一页的起始行数
                int offset = (pageNum - 1) * pageSize;

                #region 生成查询语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT ii.inventoryID,ii.InventoryNumber,ii.userName,ii.inventoryAt,ii.propertyNumber,pd.procurementType,tp.typeName,ii.propertyName,ii.brand,ii.modelNumber,ii.serialNumber,ii.description,pd.pictures,ii.state,ii.receiptTime,ii.confirmTime  FROM " + strDBTblName + " AS ii ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON ii.propertyNumber = pd.propertyNumber ");
                sbQuerySQL.AppendLine("LEFT JOIN yara_type_property AS tp ON pd.TypeID = tp.typeID ");
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "ii.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND ii.UnitCode = '" + UnitCode + "' ");

                if (sf.Equals("0"))
                {
                    sbQuerySQL.AppendLine(" AND ii.userID = '" + userID + "' ");
                }

                if (sf.Equals("10"))
                {

                    sbQuerySQL.AppendLine(" AND ii.DepartmentCode = '" + DeptCode + "' ");
                }

                if (sf.Equals("20"))
                {
                    //  sbQuerySQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }
                if (sf.Equals("30"))
                {
                    //  sbQuerySQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }
                if (sf.Equals("100"))
                {
                    //  sbQuerySQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }

                if (sf.Equals("200"))
                {
                    //  sbQuerySQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }
                if (sf.Equals("300"))
                {
                    //  sbQuerySQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }

                if (sf.Equals("999"))
                {
                    //  sbTotsbQuerySQLalSQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }

                if (!string.IsNullOrEmpty(InventoryNumber))  //根据InventoryNumber
                {
                    sbQuerySQL.AppendLine(" AND ii.InventoryNumber = '" + InventoryNumber + "' ");
                }
            

                if (!string.IsNullOrEmpty(setID))
                {
                    sbQuerySQL.AppendLine(" AND ii.setID = '" + setID + "' ");
                }
                if (!string.IsNullOrEmpty(state))
                {
                    sbQuerySQL.AppendLine(" AND ii.state = '" + state + "' ");
                }
                if (!string.IsNullOrEmpty(procurementType))
                {
                    sbQuerySQL.AppendLine(" AND tp.procurementType = '" + procurementType + "' ");
                }

                if (!string.IsNullOrEmpty(propertyNumber))
                {
                    sbQuerySQL.AppendLine(" AND ii.propertyNumber = '" + propertyNumber + "' ");
                }
                if (!string.IsNullOrEmpty(propertyName))
                {
                    sbQuerySQL.AppendLine(" AND ii.propertyName like '%" + propertyName + "%' ");
                }
                if (!string.IsNullOrEmpty(userName))
                {
                    sbQuerySQL.AppendLine(" AND ii.userName = '" + userName + "' ");
                }

                if (!(string.IsNullOrEmpty(sDate) && string.IsNullOrEmpty(eDate)))
                {
                    sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(ii.inventoryAt, '%Y-%m-%d %H:%i:%s')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
                }
                sbQuerySQL.AppendLine("ORDER BY ii.Sys_InputDateTime DESC ");
                sbQuerySQL.AppendLine("LIMIT " + offset + " , " + pageSize);
                #endregion
                //获取数据
                string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                ob.Add("totalNum", oo["total"].Value<int>());
                ob.Add("list", JArray.Parse(list));
            }

            strRtData = ob.ToString();
            return strRtData; //数据库查询结果
        }

        // ======================首页接口=====================
        public string GetHomePageData(string strB64RequestData)
        {
            string strRtData = "no data";
            string countStr = "";
            string UserId=string.Empty; 
            string UnitCode=string.Empty;
            string RoleName=string.Empty;
            string DeptCode=string.Empty;

            string sDate = (DateTime.Now.AddDays(1 - DateTime.Now.Day).Date).ToString("yyyy-MM-dd");
            string eDate=(DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1)).ToString("yyyy-MM-dd"); 

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);
            string[] strArray = strRequestData.Split('★');  //  var strRequestData = `1★${ObjToStr(localStorage_getValue("PersonCode"))}★${ObjToStr(localStorage_getValue("UnitCode"))}`;  
            //      strRequestData = strRequestData +`★${ ObjToStr(localStorage_getValue("RoleName"))}★${ObjToStr(localStorage_getValue("DeptCode"))}`;

            string strDBGroup = "Data";   //主表数据库分组名

            string now = System.DateTime.Now.ToString("yyyy-MM");//获取当前年月
            countStr = strArray[0];
            UserId = strArray[1];
            UnitCode = strArray[2];
            RoleName = strArray[3]; 
            DeptCode = strArray[4];

            string sf = getPersonneInfo(RoleName);

            JArray list = new JArray();

            #region 获取总固定资产数sql语句
            StringBuilder sbGdTotalSQL = new StringBuilder();
            sbGdTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_property_detail ");
            sbGdTotalSQL.AppendLine("WHERE ");
            sbGdTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbGdTotalSQL.AppendLine(" AND procurementType = '1'");
            if (sf.Equals("0"))
            {
                sbGdTotalSQL.AppendLine(" AND userID = '" + UserId + "'");
            }
            if (sf.Equals("10"))
            {
                sbGdTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "'");
            }
          
            sbGdTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");
            sbGdTotalSQL.AppendLine(" AND state != '5' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbGdTotalSQL.ToString() + "  :获取总固定资产数sql语句" + DateTime.Now);

            //获取固定总资产数量
            string gdTotalNum = myDB.YookingExecuteJson(strDBGroup, sbGdTotalSQL.ToString());

            JObject gdTotalObj = JArray.Parse(gdTotalNum)[0] as JObject;
            gdTotalObj.Add("title", "总固定资产");
            gdTotalObj.Add("dw", "个");
            gdTotalObj.Add("icos", "https://xiaofang-1325886766.cos.ap-chengdu.myqcloud.com/indexData1.png");
            gdTotalObj.Add("url", "property");
            gdTotalObj.Add("sDate", "");
            gdTotalObj.Add("eDate", "");

            list.Add(gdTotalObj);

            #region 获取易耗品资产数sql语句
            StringBuilder sbDzTotalSQL = new StringBuilder();
            sbDzTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_property_detail ");
            sbDzTotalSQL.AppendLine("WHERE ");
            sbDzTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbDzTotalSQL.AppendLine(" AND procurementType = '2'");
            if (sf.Equals("0"))
            {
                sbDzTotalSQL.AppendLine(" AND userID = '" + UserId + "'");
            }
            if (sf.Equals("10"))
            {
                sbDzTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "'");
            }
            sbDzTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");
            sbDzTotalSQL.AppendLine(" AND state != '5' ");
            #endregion
            //获取易耗品总资产数量
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbDzTotalSQL.ToString() + "  :获取总低值资产数sql语句" + DateTime.Now);
            string dzTotalNum = myDB.YookingExecuteJson(strDBGroup, sbDzTotalSQL.ToString());
            JObject dzTotalObj = JArray.Parse(dzTotalNum)[0] as JObject;
            dzTotalObj.Add("title", "总低值易耗品");
            dzTotalObj.Add("dw", "个");
            dzTotalObj.Add("icos", "https://xiaofang-1325886766.cos.ap-chengdu.myqcloud.com/indexData2.png");
            dzTotalObj.Add("url", "propertyD");
            dzTotalObj.Add("sDate", "");
            dzTotalObj.Add("eDate", "");
            list.Add(dzTotalObj);

            #region 获取本月固定资产数sql语句
            StringBuilder sbGdMonthTotalSQL = new StringBuilder();
            sbGdMonthTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_property_detail ");
            sbGdMonthTotalSQL.AppendLine("WHERE ");
            sbGdMonthTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbGdMonthTotalSQL.AppendLine(" AND procurementType = '1' ");
     
            sbGdMonthTotalSQL.AppendLine(" AND LEFT(receiptTime, 7) = '" + now + "' ");
            if (sf.Equals("0"))
            {
                sbGdMonthTotalSQL.AppendLine(" AND userID = '" + UserId + "'");
            }
            if (sf.Equals("10"))
            {
                sbGdMonthTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "'");
            }
            sbGdMonthTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");

            #endregion




            //获取本月固定资产数量
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbGdMonthTotalSQL.ToString() + "  :获取本月固定资产数sql语句" + DateTime.Now);
            string gdMonthTotalNum = myDB.YookingExecuteJson(strDBGroup, sbGdMonthTotalSQL.ToString());
            JObject gdMonthTotalObj = JArray.Parse(gdMonthTotalNum)[0] as JObject;

            gdMonthTotalObj.Add("title", "本月新增固定资产");
            gdMonthTotalObj.Add("dw", "个");
            gdMonthTotalObj.Add("icos", "https://xiaofang-1325886766.cos.ap-chengdu.myqcloud.com/indexData3.png");
            //gdMonthTotalObj.Add("url", "buyFixed");
            gdMonthTotalObj.Add("url", "property");
            gdMonthTotalObj.Add("sDate", sDate);
            gdMonthTotalObj.Add("eDate", eDate);
            list.Add(gdMonthTotalObj);

            #region 获取本月易耗品资产数sql语句
            StringBuilder sbDzMonthTotalSQL = new StringBuilder();
            sbDzMonthTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_property_detail ");
            sbDzMonthTotalSQL.AppendLine("WHERE ");
            sbDzMonthTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbDzMonthTotalSQL.AppendLine(" AND procurementType = '2' ");
            if (sf.Equals("0"))
            {
                sbDzMonthTotalSQL.AppendLine(" AND userID = '" + UserId + "'");
            }
            if (sf.Equals("10"))
            {
                sbDzMonthTotalSQL.AppendLine(" AND departmentID = '" + DeptCode + "'");
            }
            sbDzMonthTotalSQL.AppendLine(" AND LEFT(receiptTime, 7) = '" + now + "' ");
            sbDzMonthTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");
            #endregion
            //获取本月易耗品资产数量
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbDzMonthTotalSQL.ToString() + "  :获取本月易耗品资产数sql语句" + DateTime.Now);
            string dzMonthTotalNum = myDB.YookingExecuteJson(strDBGroup, sbDzMonthTotalSQL.ToString());
            JObject dzMonthTotalObj = JArray.Parse(dzMonthTotalNum)[0] as JObject;
            dzMonthTotalObj.Add("title", "本月新增低值易耗品");
            dzMonthTotalObj.Add("dw", "个");
            dzMonthTotalObj.Add("icos", "https://xiaofang-1325886766.cos.ap-chengdu.myqcloud.com/indexData4.png");
            dzMonthTotalObj.Add("url", "propertyD");
            dzMonthTotalObj.Add("sDate", sDate);
            dzMonthTotalObj.Add("eDate", eDate);
            //dzMonthTotalObj.Add("url", "buyLow");
            list.Add(dzMonthTotalObj);

            #region 获取本月报修数sql语句
            StringBuilder sbBxMonthTotalSQL = new StringBuilder();
            sbBxMonthTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_fixed_repair_log ");
            sbBxMonthTotalSQL.AppendLine("WHERE ");
            sbBxMonthTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbBxMonthTotalSQL.AppendLine(" AND LEFT(repairTime,7) = '" + now + "' ");
            //sbBxMonthTotalSQL.AppendLine(" AND repairerID = '" + UserId + "'");

            if (sf.Equals("0"))
            {
                sbBxMonthTotalSQL.AppendLine(" AND repairerID = '" + UserId + "'");
            }
            if (sf.Equals("10"))
            {
                sbBxMonthTotalSQL.AppendLine(" AND repairerDepartmentID = '" + DeptCode + "'");
            }

            sbBxMonthTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");

            #endregion
            //获取本月报修数量
            //myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbBxMonthTotalSQL.ToString() + "  :获取本月报修数sql语句" + DateTime.Now);
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbBxMonthTotalSQL.ToString() + "  :获取本月报修数sql语句" + DateTime.Now);
            string bxMonthTotalNum = myDB.YookingExecuteJson(strDBGroup, sbBxMonthTotalSQL.ToString());
            JObject bxMonthTotalObj = JArray.Parse(bxMonthTotalNum)[0] as JObject;
            bxMonthTotalObj.Add("title", "本月维护资产");
            bxMonthTotalObj.Add("dw", "个");
            bxMonthTotalObj.Add("icos", "https://xiaofang-1325886766.cos.ap-chengdu.myqcloud.com/indexData5.png");
            bxMonthTotalObj.Add("url", "fixedRepair");
            bxMonthTotalObj.Add("sDate", sDate);
            bxMonthTotalObj.Add("eDate", eDate);

            list.Add(bxMonthTotalObj);

            #region 获取本月转移数sql语句
            StringBuilder sbZyMonthTotalSQL = new StringBuilder();
            sbZyMonthTotalSQL.AppendLine("SELECT count(*) AS nums FROM yara_fixed_transfer_log ");
            sbZyMonthTotalSQL.AppendLine("WHERE ");
            sbZyMonthTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbZyMonthTotalSQL.AppendLine(" AND LEFT(transferAt, 7) = '" + now + "' ");

            if (sf.Equals("0"))
            {
                sbZyMonthTotalSQL.AppendLine(" AND ( ransferorID = '" + UserId + "' or shiftToID='" + UserId + "') ");
            }
            if (sf.Equals("10"))
            {
                sbZyMonthTotalSQL.AppendLine(" AND ( ransferorDepartmentID = '" + DeptCode + "' or shiftToDepartment='" + DeptCode + "') ");
            }
        
            sbZyMonthTotalSQL.AppendLine(" AND UnitCode = '" + UnitCode + "'");
            #endregion
            //获取本月转移数量
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbZyMonthTotalSQL.ToString() + "  :获取本月转移数sql语句" + DateTime.Now);
            string zyMonthTotalNum = myDB.YookingExecuteJson(strDBGroup, sbZyMonthTotalSQL.ToString());
            JObject zyMonthTotalObj = JArray.Parse(zyMonthTotalNum)[0] as JObject;
            zyMonthTotalObj.Add("title", "本月转移/退回资产");
            zyMonthTotalObj.Add("dw", "个");
            zyMonthTotalObj.Add("icos", "https://xiaofang-1325886766.cos.ap-chengdu.myqcloud.com/indexData6.png");
            zyMonthTotalObj.Add("url", "fixedTransferMainSum");
            zyMonthTotalObj.Add("sDate", sDate);
            zyMonthTotalObj.Add("eDate", eDate);
            list.Add(zyMonthTotalObj);

            clsDBSpace mySpace = new clsDBSpace(); //字典表空间名
            string strSysSapace = mySpace.GetDBSpaceName("Dict");

            #region 获取本月盘点数sql语句


            StringBuilder sbPdMonthSQL = new StringBuilder();
            sbPdMonthSQL.AppendLine("SELECT yp.DictMemo AS name , count(yii.state) AS value FROM " + strSysSapace + ".Dict_yara_pdzt AS yp ");
            sbPdMonthSQL.AppendLine("LEFT JOIN ( SELECT state FROM yara_inventory_info WHERE " + clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (sf.Equals("0"))
            {
                sbPdMonthSQL.AppendLine(" AND UserId='" + UserId + "' ");
            }
            if (sf.Equals("10"))
            {
                sbPdMonthSQL.AppendLine(" AND DepartmentCode='" + DeptCode + "' ");
            }
            sbPdMonthSQL.AppendLine(" AND LEFT(inventoryAt, 7) = '" + now + "' ) AS yii ON yii.state = yp.DictCode ");

            //sbPdMonthSQL.AppendLine( " AND LEFT(inventoryAt, 7) = '" + now + "' ) AS yii ON yii.state = yp.DictCode ");


            sbPdMonthSQL.AppendLine("GROUP BY yp.DictCode ");
            #endregion
            //获取本月盘点
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbPdMonthSQL.ToString() + "  :获取本月盘点数sql语句" + DateTime.Now);

            string pdStr = myDB.YookingExecuteJson(strDBGroup, sbPdMonthSQL.ToString());

            #region 获取本月维修sql语句
            StringBuilder sbWxMonthSQL = new StringBuilder();
            sbWxMonthSQL.AppendLine("SELECT yw.DictMemo AS name , count(yfr.state) AS value FROM " + strSysSapace + ".Dict_yara_wxzt AS yw ");
            sbWxMonthSQL.AppendLine("LEFT JOIN ( SELECT state FROM yara_fixed_repair_log WHERE" + clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));

            if (sf.Equals("0"))
            {
                sbWxMonthSQL.AppendLine(" AND repairerID='" + UserId + "' ");
            }
            if (sf.Equals("10"))
            {
                sbWxMonthSQL.AppendLine(" AND repairerDepartmentID='" + DeptCode + "' ");
            }

            sbWxMonthSQL.AppendLine(" AND LEFT(repairTime,7) = '" + now + "' ) AS yfr ON yfr.state = yw.DictCode ");
            sbWxMonthSQL.AppendLine("GROUP BY yw.DictCode ");
            #endregion
            //获取本月盘点
            myLog.WriteInfoToTxtFile("SysLog", "IndexDataSQL.txt", sbWxMonthSQL.ToString() + "  :获取本月盘点数sql语句" + DateTime.Now);
            string wxStr = myDB.YookingExecuteJson(strDBGroup, sbWxMonthSQL.ToString());
            JObject obj = new JObject();
            obj.Add("countNum", list);
            obj.Add("pdList", JArray.Parse(pdStr));
            obj.Add("wxList", JArray.Parse(wxStr));

            strRtData = obj.ToString();
            return strRtData;
        }

        // ======================广告轮播图接口=====================
        // 获取广告类轮播图列表
        public string GetYaraAdList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_ad"; //主表库名称
            string isShow = ""; //是否显示 1 显示 2 隐藏

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length > 0)
            {
                isShow = strArray[0];
            }
            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT AdID,AdPic,AdTitle,ToUrl,isShow,SYS_RECORDID AS strRecordID  FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(isShow))
            {
                sbQuerySQL.AppendLine(" AND isShow = '" + isShow + "' ");
            }
            #endregion

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                strRtData = JArray.Parse(list).ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData;
        }

        // ======================资讯类轮播图接口=====================
        // 获取资讯类轮播图列表
        public string GetYaraInformationList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_information"; //主表库名称
            string isShow = ""; //是否显示 1 显示 2 隐藏

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length > 0)
            {
                isShow = strArray[0];
            }
            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT informationID,title,cover,Content,isShow  FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(isShow))
            {
                sbQuerySQL.AppendLine(" AND isShow = '" + isShow + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                strRtData = JArray.Parse(list).ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData;
        }

        //========================= 模版消息 =============
        public string SendTemplateMessaage(string strB64RequestData)
        {
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            /**
             * 0★审批人id★2★3★4★5★url★openId
             * 1★审批人id★2★3★4★5★6★url★openId
             * 模版消息分类 0: skf2tnDLAGTvEkjFX4rQltMiHja3X-CZg8fTdyQmjlg   1 : skf2tnDLAGTvEkjFX4rQlkI750b4yl8w5zavJ2NriU4
             */

            string touser = ""; // 接收者的OpenID
            string value = "value";
            string str = "";//参数字符串
            string templateId = "";//模版id
            string url = "";//跳转链接
            if (strArray[0].Equals("0"))
            {
                touser = strArray[7];
                templateId = "skf2tnDLAGTvEkjFX4rQltMiHja3X-CZg8fTdyQmjlg";
                url = strArray[6];
                str = " {\"thing20\": {" + value + ": " + strArray[2] + "},\"thing3\": {" + value + ": " + strArray[3] + "},\"thing9\": {" + value + ": " + strArray[4] + "},\"thing10\": {" + value + ": " + strArray[5] + "}}";
            } else if (strArray[0].Equals("1"))
            {
                touser = strArray[8];
                templateId = "skf2tnDLAGTvEkjFX4rQlkI750b4yl8w5zavJ2NriU4";
                url = strArray[7];
                str = " {\"thing20\": {" + value + ": " + strArray[2] + "},\"thing3\": {" + value + ": " + strArray[3] + "},\"thing9\": {" + value + ": " + strArray[4] + "},\"thing10\": {" + value + ": " + strArray[5] + "},\"amount26\": {" + value + ": " + strArray[6] + "}}";
            }
            clsWxOffical.SendTemplateMessageAsync(touser, templateId, JObject.Parse(str), url);
            return "发送成功";
        }
        //========================= 获取部门树 =============
        public string GetDeptTreeList(string strB64RequestData)
        {

            string strRtData = "no data";
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "Sa_Org_Department"; //主表库名称

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            #region 生成查询sql语句
            StringBuilder sbDeptSQL = new StringBuilder();
            sbDeptSQL.AppendLine("SELECT DeptCode AS DEPTCODE,DeptName AS DEPTNAME FROM " + strDBTblName + " ");
            sbDeptSQL.AppendLine("WHERE ");
            sbDeptSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(strArray[0]))
            {
                sbDeptSQL.AppendLine(" AND UnitCode = '" + strArray[0] + "' ");
            }
            #endregion

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbDeptSQL.ToString());

            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                JArray deptList = JArray.Parse(list);
                foreach (JObject item in deptList)
                {

                    StringBuilder sbPersonInfoSQL = new StringBuilder();
                    sbPersonInfoSQL.AppendLine("SELECT te.*,ydp.ISXZGLY,ydp.ISCWGLY,ydp.ISRSGLY,ydp.SF,ydp.depPerID,ydp.ISCWZJ,ydp.ISZJL,ydp.ISGLY,ydp.gzhOpenid,ydp.userName FROM ( ");
                    sbPersonInfoSQL.AppendLine("SELECT DISTINCT sop.PERSONCODE,sop.PersonName AS PERSONNAME,sop.Email AS email FROM Sa_Org_StaffInfo AS s ");
                    sbPersonInfoSQL.AppendLine("RIGHT JOIN Sa_Org_PersonInfo AS sop ON s.PersonID = sop.PersonID ");
                    sbPersonInfoSQL.AppendLine("WHERE ");
                    sbPersonInfoSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "sop.SYS_CANCELDATETIME "));
                    sbPersonInfoSQL.AppendLine(" AND s.DeptCode = '" + (string)item["DEPTCODE"] + "' GROUP BY sop.PERSONCODE,PERSONNAME,email ) AS te  ");
                    sbPersonInfoSQL.AppendLine("LEFT JOIN yara_dep_per AS ydp ON te.PERSONCODE = ydp.PERSONCODE AND ydp.DEPTCODE = '" + (string)item["DEPTCODE"] + "' ");
                    string list1 = myDB.YookingExecuteJson(strDBGroup, sbPersonInfoSQL.ToString());
                    if (!"{\"result\":\"yooking null\"}".Equals(list1))
                    {
                        item.Add("LIST", JArray.Parse(list1));
                    } else
                    {
                        item.Add("LIST", new JArray());
                    }
                }
                strRtData = deptList.ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData;
        }
        //========================= 同步部门人员到表 yara_dep_per ======================
        public string SynPersonToDep(string strB64RequestData)
        {
            string str = "";
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "Sa_Org_Department"; //主表库名称

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            #region 生成查询sql语句
            StringBuilder sbDeptSQL = new StringBuilder();
            sbDeptSQL.AppendLine("SELECT DeptCode AS DEPTCODE,DeptName AS DEPTNAME,UNITCODE FROM " + strDBTblName + " ");
            sbDeptSQL.AppendLine("WHERE ");
            sbDeptSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(strArray[0]))
            {
                sbDeptSQL.AppendLine(" AND UnitCode = '" + strArray[0] + "' ");
            }
            #endregion

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbDeptSQL.ToString());
            JArray arr = new JArray();
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                JArray deptList = JArray.Parse(list);
                foreach (JObject item in deptList)
                {
                    StringBuilder sbPersonInfoSQL = new StringBuilder();
                    sbPersonInfoSQL.AppendLine("SELECT DISTINCT sop.PERSONCODE,sop.PersonName AS PERSONNAME,sop.Email AS email FROM Sa_Org_StaffInfo AS s ");
                    sbPersonInfoSQL.AppendLine("RIGHT JOIN Sa_Org_PersonInfo AS sop ON s.PersonID = sop.PersonID ");
                    sbPersonInfoSQL.AppendLine("WHERE ");
                    sbPersonInfoSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "sop.SYS_CANCELDATETIME "));
                    sbPersonInfoSQL.AppendLine(" AND s.DeptCode = '" + (string)item["DEPTCODE"] + "' ");
                    sbPersonInfoSQL.AppendLine("GROUP BY sop.PERSONCODE,PERSONNAME,email");
                    
                    string list1 = myDB.YookingExecuteJson(strDBGroup, sbPersonInfoSQL.ToString());
                    if (!"{\"result\":\"yooking null\"}".Equals(list1))
                    {
                        JArray personList = JArray.Parse(list1);
                        foreach (JObject p in personList)
                        {
                            //用部门id和人员id查询是否存在当前的这个人
                            StringBuilder selectDepPersonSQL = new StringBuilder();
                            string sql = "SELECT * FROM yara_dep_per WHERE DEPTCODE = '" + (string)item["DEPTCODE"] + "' AND PERSONCODE = '" + (string)p["PERSONCODE"] + "'";
                            string list2 = myDB.YookingExecuteJson(strDBGroup, sql);
                            if ("{\"result\":\"yooking null\"}".Equals(list2))
                            {
                                //插入人员
                                JObject o = new JObject();
                                o.Add("depPerID", Guid.NewGuid().ToString());
                                o.Add("UnitCode", (string)item["UNITCODE"]);
                                o.Add("DEPTCODE", (string)item["DEPTCODE"]);
                                o.Add("DEPTNAME", (string)item["DEPTNAME"]);
                                o.Add("PERSONCODE", (string)p["PERSONCODE"]);
                                o.Add("PERSONNAME", (string)p["PERSONNAME"]);
                                o.Add("email", (string)p["email"]);
                                o.Add("SF", "0");
                                o.Add("ISCWZJ", "0");
                                o.Add("ISZJL", "0");
                                arr.Add(o);
                            }
                        }
                    }
                }
                str = arr.ToString();
            }
            return str;
        }

        //========================= 审批流方法 =============
        public string GetSPList(string strB64RequestData)
        {
            JArray arr = new JArray();
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);


            //这些参数用★分隔开，客户端与服务器端要一致    参数顺序: 人员id★部门id★审批类型    审批类型的值  //1:固定资产采购   2:固定资产转移   3:无   4:低值非易耗品采购 5:固定报废审批 6：低值报废审批处置
            string[] strArray = strRequestData.Split('★');

           // var strRequestData = `${ jsonObj.PERSONCODE}★${ jsonObj.DEPTCODE}★${ jsonObj.type}★${ ObjToStr(localStorage_getValue("UnitCode"))}`;

            string UnitCode = strArray[3].ToString(); //公司的代码
            JObject applyPerson = GetPersonInfo(strArray[0], strArray[1]);//申请人
            JObject deptJL = GetDeptManagerInfo(strArray[1],UnitCode);//部门经理
            JObject CWZJ = GetCWZJInfo(UnitCode);//财务总监
            JObject ZJL = GetZJLInfo(UnitCode);//总经理
            //JObject CWGLY = new JObject(); //财务管理员
            JObject CWGLY = GetCWGLY(UnitCode); //财务管理员


            JObject qsPerson = qsPersonInfo(strArray[0], strArray[1]);//签收人



            if (strArray[2].Equals("1") || strArray[2].Equals("3"))  //固定资产采购审批 fan20250404
            {

                if ((string)applyPerson["personName"] == (string)CWZJ["personName"])  //申请人为财务总监
                {
                    arr.Add(applyPerson);//添加申请人
                                         //arr.Add(CWZJ);//添加财务总监
                    if (!((string)ZJL["PERSONNAME"] == "未设置"))
                        arr.Add(ZJL);//添加总经理
                    else
                        arr.Add(applyPerson);//添加申请人
                }

                else if ((string)applyPerson["personName"] == (string)ZJL["personName"]) //申请人为总经理
                {
                    arr.Add(applyPerson);//添加申请人
                                         //arr.Add(CWZJ);//添加财务总监
                    arr.Add(ZJL);//添加总经理
                }
                else if ((string)applyPerson["personName"] == (string)deptJL["personName"])//申请人部门经理
                {
                    arr.Add(applyPerson);//添加申请人
                    if (((string)CWZJ["PERSONNAME"] == "未设置") && ((string)ZJL["PERSONNAME"] == "未设置"))
                        arr.Add(applyPerson);//添加申请人
                    else
                    {
                        if (!((string)CWZJ["PERSONNAME"] == "未设置"))
                            arr.Add(CWZJ);//添加财务总监
                        if (!((string)ZJL["PERSONNAME"] == "未设置"))
                            arr.Add(ZJL);//添加总经理
                    }
                }
                else
                {
                    arr.Add(applyPerson);//添加申请人

                    if (((string)CWZJ["PERSONNAME"] == "未设置") && ((string)ZJL["PERSONNAME"] == "未设置") && ((string)deptJL["PERSONNAME"] == "未设置"))
                        arr.Add(applyPerson);//添加申请人
                    else
                    {

                        if (!((string)deptJL["PERSONNAME"] == "未设置"))
                            arr.Add(deptJL);//添加部门经理

                        if (!((string)CWZJ["personName"] == (string)deptJL["personName"])) //财务经理和部门经理为同一人 仅添加一个       
                                                                                           //if (!((string)CWZJ["PERSONNAME"] == "未设置"))
                            arr.Add(CWZJ);//添加财务总监

                        if (!((string)ZJL["PERSONNAME"] == "未设置"))
                            arr.Add(ZJL);//添加总经理

                    }

                }

                return arr.ToString();

            }


            //转移审批 fan20250404
            else if (strArray[2].Equals("2"))//转移审批 fan20250404
            {
                arr.Add(applyPerson);//添加申请人

                if ((string)applyPerson["personName"] == (string)ZJL["personName"]) //申请人为总经理
                {
                    //arr.Add(applyPerson);//添加申请人
                    //                     //arr.Add(CWZJ);//添加财务总监


                    if (!((string)ZJL["PERSONNAME"] == "未设置"))
                        arr.Add(ZJL);//添加总经理
                    else
                        arr.Add(applyPerson);//添加申请人
                   // arr.Add(ZJL);//添加总经理
                }

                 else if ((string)applyPerson["personName"] == (string)CWZJ["personName"]) //申请人为财务总监
                {
                    //arr.Add(applyPerson);//添加申请人
                    //                     //arr.Add(CWZJ);//添加财务总监
                    if (!((string)CWZJ["PERSONNAME"] == "未设置"))
                        arr.Add(CWZJ);//添加总经理
                    else
                        arr.Add(applyPerson);//添加申请人
                   // arr.Add(ZJL);//添加总经理
                }
                else
                {
                    arr.Add(deptJL);//添加部门经理
                }

                arr.Add(qsPerson);//签收人  最后添加签收人

                return arr.ToString();
            }
            else if ( strArray[2].Equals("4"))//低值易耗品采购审批 fan20250404
            {
                arr.Add(applyPerson);//添加申请人

                if ((string)applyPerson["personName"] == (string)ZJL["personName"]) //申请人为总经理
                {
                    //arr.Add(applyPerson);//添加申请人
                    //                     //arr.Add(CWZJ);//添加财务总监
                    arr.Add(ZJL);//添加总经理
                }
                else if ((string)applyPerson["personName"] == (string)CWZJ["personName"]) //申请人为总经理
                {
                    //arr.Add(applyPerson);//添加申请人
                    //                     //arr.Add(CWZJ);//添加财务总监
                    arr.Add(CWZJ);//添加总经理
                }
                else
                {
                    arr.Add(deptJL);//添加部门经理
                }
                //arr.Add(deptJL);//添加部门经理
                return arr.ToString();
            }
            else if (strArray[2].Equals("5"))            //固定资产报废审批
            {
                if ("1".Equals((string)applyPerson["ISCWZJ"]) || "1".Equals((string)applyPerson["ISZJL"]))
                {
                    arr.Add(applyPerson);//添加申请人
                    arr.Add(CWGLY);//添加财务管理员
                    arr.Add(ZJL);//添加总经理
                }
                else
                {
                    arr.Add(applyPerson);//添加申请人
                    arr.Add(CWGLY);//添加财务管理员
                    arr.Add(deptJL);//添加部门经理
                    arr.Add(ZJL);//添加总经理
                }
                return arr.ToString();
            }
            else if (strArray[2].Equals("6"))            //低值资产报废审批
            {
                if ("1".Equals((string)applyPerson["ISCWZJ"]) || "1".Equals((string)applyPerson["ISZJL"]))
                {
                    arr.Add(applyPerson);//添加申请人
                    arr.Add(applyPerson);//添加总经理
                }
                else
                {
                    arr.Add(applyPerson);//添加申请人
                    arr.Add(deptJL);//添加部门经理
                   // arr.Add(ZJL);//添加总经理
                }
                return arr.ToString();
            }
            else
            {
                return "啥也不是";
            }
        }


        //签收
        public JObject qsPersonInfo(string personCode, string deptCode)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " + strDBTblName + " AS p ");
            sbQuerySQL.Append("LEFT JOIN Sa_Org_PersonInfo AS op ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine("p.PERSONCODE = '" + personCode + "' ");
            sbQuerySQL.AppendLine(" AND p.DEPTCODE = '" + deptCode + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                JObject o = JArray.Parse(list)[0] as JObject;
                o.Add("PERSONNAME", o["personName"] + " (签收人)");
                o.Add("state", "0");
                o.Add("active", "1");
                o.Add("myState", "1");
                o.Add("title", "待签收");
                o.Add("info", o["DEPTNAME"].ToString() + o["personName"].ToString() + "待签收");
                if (GetQm(o["WorkNumber"].ToString()) != null)
                {
                    o.Add("qm", GetQm(o["WorkNumber"].ToString())["qm"].ToString());
                }
                else
                {
                    o.Add("qm", "");
                }
                return o;
            }
            return new JObject();
        }


        //根据使用人id获取使用人信息
        public JObject GetPersonInfo(string personCode, string deptCode)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " + strDBTblName + " AS p ");
            sbQuerySQL.Append("LEFT JOIN Sa_Org_PersonInfo AS op ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine("p.PERSONCODE = '" + personCode + "' ");
            sbQuerySQL.AppendLine(" AND p.DEPTCODE = '" + deptCode + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                JObject o = JArray.Parse(list)[0] as JObject;
                o.Add("PERSONNAME", o["personName"] +" (使用人)");
                o.Add("state", "0");
                o.Add("active", "1");
                o.Add("myState", "1");
                o.Add("title", "发起审批");
                o.Add("info", o["DEPTNAME"].ToString() + o["personName"].ToString() + "发起审批");
                if (GetQm(o["WorkNumber"].ToString()) != null)
                {
                    o.Add("qm", GetQm(o["WorkNumber"].ToString())["qm"].ToString());
                }
                else
                {
                    o.Add("qm", "");
                }
                return o;
            }
            return new JObject();
        }


        /// <summary>
        /// 返回财务管理的相关信息
        /// </summary>
        /// <param name="UnitCode">公司代码</param>
        /// <returns></returns>
        public JObject GetCWGLY(string UnitCode)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "sa_usr_useraccredit"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.Append("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " +
                strDBTblName + " as suu ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_rule_roleinfo as srr ON srr.ROLEID = suu.ROLEID ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_org_staffinfo as sos ON sos.StaffID = suu.STAFFID ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_org_personinfo as op ON op.PERSONID = sos.PERSONID ");
            sbQuerySQL.AppendLine("LEFT JOIN yara_dep_per as p ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(" srr.ROLENAME = '财务管理员' and p.UnitCode='" + UnitCode+ "' GROUP BY p.userName");  



            //sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " + strDBTblName + " AS p ");
            //sbQuerySQL.Append("LEFT JOIN Sa_Org_PersonInfo AS op ON p.PERSONCODE = op.PERSONCODE ");
            //sbQuerySQL.AppendLine("WHERE ");
            //sbQuerySQL.AppendLine("p.ISCWZJ = '1' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            JObject o = new JObject();
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                o = JArray.Parse(list)[0] as JObject;
                o.Add("PERSONNAME", o["personName"] + " (财务管理员)");
                o.Add("state", "0");
                o.Add("active", "1");
                o.Add("myState", "0");
                o.Add("title", "待审批");
                o.Add("info", "");
                if (GetQm(o["WorkNumber"].ToString()) != null)
                {
                    o.Add("qm", GetQm(o["WorkNumber"].ToString())["qm"].ToString());
                }
                else
                {
                    o.Add("qm", "");
                }
            }
            else
            {
                o.Add("PERSONNAME", "未设置");
                o.Add("title", "财务管理员");
            }
            return o;
        }

        
        //根据部门编号获取部门经理信息
        public JObject GetDeptManagerInfo(string deptCode,string Unitcode)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " + strDBTblName + " AS p ");
            sbQuerySQL.Append("LEFT JOIN Sa_Org_PersonInfo AS op ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine("p.DEPTCODE = '" + deptCode + "' ");
            sbQuerySQL.AppendLine(" AND p.SF = '1' ");
            sbQuerySQL.AppendLine(" AND p.Unitcode = '"+ Unitcode + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            JObject o = new JObject();
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                o = JArray.Parse(list)[0] as JObject;
                o.Add("PERSONNAME", o["personName"] + " (部门经理)");
                o.Add("state", "0");
                o.Add("active", "1");
                o.Add("myState", "0");
                o.Add("title", "待审批");
                o.Add("info", "");
                if (GetQm(o["WorkNumber"].ToString()) != null)
                {
                    o.Add("qm", GetQm(o["WorkNumber"].ToString())["qm"].ToString());
                }
                else
                {
                    o.Add("qm", "");
                }
            }
            else
            {
                o.Add("PERSONNAME", "未设置");
                o.Add("title", "部门经理");
            }
            
            return o;
        }
        //获取财务总监信息
        public JObject GetCWZJInfo(string Unitcode)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " + strDBTblName + " AS p ");
            sbQuerySQL.Append("LEFT JOIN Sa_Org_PersonInfo AS op ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine("p.ISCWZJ = '1' and p.UnitCode='"+ Unitcode + "'");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            JObject o = new JObject();
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                o = JArray.Parse(list)[0] as JObject;
                o.Add("PERSONNAME", o["personName"] + " (财务总监)");
                o.Add("state", "0");
                o.Add("active", "1");
                o.Add("myState", "0");
                o.Add("title", "待审批");
                o.Add("info", "");
                if (GetQm(o["WorkNumber"].ToString()) != null)
                {
                    o.Add("qm", GetQm(o["WorkNumber"].ToString())["qm"].ToString());
                }
                else
                {
                    o.Add("qm", "");
                }
            } 
            else
            {
                o.Add("PERSONNAME", "未设置");
                o.Add("title", "财务总监");
            }
            return o;
        }
        //获取总经理信息
        public JObject GetZJLInfo(string Unitcode)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber FROM " + strDBTblName + " AS p ");
            sbQuerySQL.Append("LEFT JOIN Sa_Org_PersonInfo AS op ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine("p.ISZJL = '1' ");
            sbQuerySQL.AppendLine(" AND p.Unitcode = '" + Unitcode + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            JObject o = new JObject();
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                o = JArray.Parse(list)[0] as JObject;
                o.Add("PERSONNAME", o["personName"] + " (总经理)");
                o.Add("state", "0");
                o.Add("active", "1");
                o.Add("myState", "0");
                o.Add("title", "待审批");
                o.Add("info", "");
                if (GetQm(o["WorkNumber"].ToString()) != null)
                {
                    o.Add("qm", GetQm(o["WorkNumber"].ToString())["qm"].ToString());
                } else
                {
                    o.Add("qm", "");
                }
            }
            else
            {
                o.Add("PERSONNAME", "未设置");
                o.Add("title", "总经理");
            }
            return o;
        }
        //根据工号获取签名信息
        public JObject GetQm(string workNumber)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_wx_user"; //库表名称

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT qm FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine("workNumber = '" + workNumber + "' ");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                JObject o = JArray.Parse(list)[0] as JObject;
                return o;
            }
            return null;
        }
        //取消管理员
        public string SetGLYQX(string strB64RequestData)
        {
            object objResult = 0; //受影响的行数

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称


            //这些参数用★分隔开，客户端与服务器端要一致  参数格式   人员code★财务总监或总经理字段
            string[] strArray = strRequestData.Split('★');
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
         
            #region 生成根据人员id修改所有的SQL语句
            StringBuilder updateSQL = new StringBuilder();
            updateSQL.AppendLine(" UPDATE " + strDBTblName + " SET ");
            updateSQL.AppendLine(strArray[1] + " = '0' ");
            updateSQL.AppendLine("WHERE ");
            updateSQL.AppendLine(" PERSONCODE = '" + strArray[0] + "' ");
            #endregion
            objResult = myDB.YookingExecuteNonQuery(strDBGroup, updateSQL.ToString());
            return objResult.ToString(); //返回数据库操作的结果
        }

        //设置财务总监或者总经理或者管理员
        public string SetCWZJL(string strB64RequestData)
        {
            object objResult = 0; //受影响的行数

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_dep_per"; //库表名称

         
            //这些参数用★分隔开，客户端与服务器端要一致  参数格式   人员code★财务总监或总经理字段
            string[] strArray = strRequestData.Split('★');
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
        if (!("ISXZGLY".Equals(strArray[1])|| "ISCWGLY".Equals(strArray[1])|| "ISRSGLY".Equals(strArray[1]))) {

            #region 生成修改所有的SQL语句
            StringBuilder sbUpdateSQL = new StringBuilder();
            sbUpdateSQL.AppendLine(" UPDATE " + strDBTblName + " SET ");
            sbUpdateSQL.AppendLine(strArray[1] + " = '0' ");
            sbUpdateSQL.AppendLine("WHERE ");
            sbUpdateSQL.AppendLine(" 1 = 1 ");
            #endregion
            myDB.YookingExecuteNonQuery(strDBGroup, sbUpdateSQL.ToString());

            } 

            #region 生成根据人员id修改所有的SQL语句
            StringBuilder updateSQL = new StringBuilder();
            updateSQL.AppendLine(" UPDATE " + strDBTblName + " SET ");
            updateSQL.AppendLine(strArray[1] + " = '1' ");
            updateSQL.AppendLine("WHERE ");
            updateSQL.AppendLine(" PERSONCODE = '" + strArray[0] + "' ");
            updateSQL.AppendLine(" AND  UnitCode = '" + strArray[2] + "' ");
            #endregion
          

            objResult = myDB.YookingExecuteNonQuery(strDBGroup, updateSQL.ToString());
            return objResult.ToString(); //返回数据库操作的结果
        }
        //=============== 发送邮件 =======================
        public string SendEmail(string strB64RequestData)
        {

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //这些参数用★分隔开，客户端与服务器端要一致  参数格式 接收人★主题★邮件正文
            string[] strArray = strRequestData.Split('★');
            clsEmail.SendEmail("smtp.163.com", "", "", strArray[0], strArray[1], strArray[2]);
            return "操作成功"; //返回数据库操作的结果
        }
        //=============== 根据资产类别和采购类型生成资产编号 =======================
        public string GetZCNo(string strB64RequestData)
        {
            string strDBGroup = "Data";   //数据库分组名
            string strDBTblName = "yara_type_property"; //库表名称
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            //这些参数用★分隔开，客户端与服务器端要一致  参数格式 typeID★采购类型
            string[] strArray = strRequestData.Split('★');

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT typeNumber FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND typeID = '" + strArray[0] + "' ");

            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            if ("{\"result\":\"yooking null\"}".Equals(list))
            {
                return "不存在该分类的资产"; //返回数据库操作的结果
            }
            //资产分类编码
            JObject o = JArray.Parse(list)[0] as JObject;
            string str = (string)o["typeNumber"];

            //获取已入库的总数
            #region 生成查询sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT COUNT(detailID) AS total FROM yara_property_detail ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND TypeID = '" + strArray[0] + "' ");
            sbTotalSQL.AppendLine(" AND procurementType = '" + strArray[1] + "' ");
            #endregion

            //获取列表字符串
            string co = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            if ("{\"result\":\"yooking null\"}".Equals(co))
            {
                o.Add("num", 0);
                return o.ToString(); //返回数据库操作的结果
            }

            JObject count = JArray.Parse(co)[0] as JObject;
            o.Add("num", count["total"].Value<int>());
            return o.ToString(); //返回数据库操作的结果
        }
        //========== 判断一个数是否是5位数,不是则在前面添加 0
        private static string PadToFiveDigits(int number)
        {
            // 将数字转换为字符串
            string numberStr = number.ToString();

            // 判断字符串长度是否小于5
            if (numberStr.Length < 5)
            {
                // 在前面补0直到长度为5
                return numberStr.PadLeft(5, '0');
            }
            else
            {
                // 如果已经是5位或更多位，则直接使用原字符串
                return numberStr;
            }
        }
        // 获取批量发送邮件人员列表
        public string GetBatchSendEmailList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_email_set"; //主表库名称

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT ID,name,info,emaillist  FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
                                                      //获取列表字符串
            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                strRtData = JArray.Parse(list).ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData;
        }
        
        public string GetPersonInfoList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "Sa_Org_StaffInfo"; //主表库名称

            //这些参数用★分隔开，客户端与服务器端要一致 单位★姓名
            string[] strArray = strRequestData.Split('★');

            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT p.PersonID,concat(p.PersonName,' | ',p.WorkNumber) as name, p.Email FROM " + strDBTblName + " a ");
            sbQuerySQL.AppendLine("LEFT JOIN Sa_Org_PersonInfo AS p ON p.PersonID = a.PersonID ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "a.SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND a.UnitCode = '" + strArray[0] + "' ");
            //if (!string.IsNullOrEmpty(strArray[0]))
            //{
            //    sbQuerySQL.AppendLine(" AND a.UnitCode = '" + strArray[0] + "' ");
            //}
            if (!string.IsNullOrEmpty(strArray[1]))
            {
                sbQuerySQL.AppendLine(" AND p.PersonName LIKE '%" + strArray[1] + "%' ");
            }
            sbQuerySQL.AppendLine("GROUP BY p.PersonID,name,p.Email");
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            string list = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());

            clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            myLog.WriteInfoToTxtFile("SysLog", "yangqi_sql1.txt", sbQuerySQL.ToString());


            if (!"{\"result\":\"yooking null\"}".Equals(list))
            {
                strRtData = JArray.Parse(list).ToString();
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData;
        }
        public string GetCountStatusNum(string strB64RequestData)
        {
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);
            //这些参数用★分隔开，客户端与服务器端要一致 人员id
            string[] strArray = strRequestData.Split('★');
            JObject o = new JObject();
            string gb = GetBuyNum("1", strArray[0]);
            if (string.IsNullOrEmpty(gb))
            {
                o.Add("gzccg","0");
            } else
            {
                o.Add("gzccg",gb);
            }
            string db = GetBuyNum("2", strArray[0]);
            if (string.IsNullOrEmpty(db))
            {
                o.Add("dzcg","0");
            } else
            {
                o.Add("dzcg",db);
            }
            string gz = GetZyNum("1", strArray[0]);
            if (string.IsNullOrEmpty(gz))
            {
                o.Add("gzczy","0");
            } else
            {
                o.Add("gzczy",gz);
            }
            string dz = GetZyNum("2", strArray[0]);
            if (string.IsNullOrEmpty(dz))
            {
                o.Add("dzzy","0");
            }
            else
            {
                o.Add("dzzy",dz);
            }
            string bf = GetBfNum(strArray[0]);
            if (string.IsNullOrEmpty(bf))
            {
                o.Add("bf", "0");
            }
            else
            {
                o.Add("bf", bf);
            }
            return o.ToString();
        }
        public string GetBuyNum(string type,string personCode)
        {
            string strDBGroup = "Data";
            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT count(buyID) as total FROM yara_buy_property ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND state = '0' ");
            if (!string.IsNullOrEmpty(type))
            {
                sbQuerySQL.AppendLine(" AND procurementType = '" + type + "' ");
            }
            if (!string.IsNullOrEmpty(personCode))
            {
                sbQuerySQL.AppendLine(" AND spuserID = '" + personCode + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            string str = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
            JObject o = JArray.Parse(str)[0] as JObject;
            return o["total"].ToString();
        }
        public string GetBfNum(string personCode)
        {
            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_scrap_set"; //主表库名称
            
            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(iID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND state = '0' ");
            if (!string.IsNullOrEmpty(personCode))
            {
                sbTotalSQL.AppendLine(" AND spuserID = '" + personCode + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject o = JArray.Parse(str)[0] as JObject;
            return o["total"].ToString();
        }
        public string GetZyNum(string type, string personCode)
        {
            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_transfer_set"; //主表库名称
            #region 生成总条数sql语句
            StringBuilder sbTotalSQL = new StringBuilder();
            sbTotalSQL.AppendLine("SELECT count(iID) AS total FROM " + strDBTblName + " ");
            sbTotalSQL.AppendLine("WHERE ");
            sbTotalSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalSQL.AppendLine(" AND state = '0' ");
            if (!string.IsNullOrEmpty(personCode))
            {
                sbTotalSQL.AppendLine(" AND spuserID = '" + personCode + "' ");
            }
            if (!string.IsNullOrEmpty(type))
            {
                sbTotalSQL.AppendLine(" AND procurementType = '" + type + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取总条数
            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalSQL.ToString());
            JObject o = JArray.Parse(str)[0] as JObject;
            return o["total"].ToString();
        }
        // 0 普通人 1 部门经理 2 财务总监或总经理
        public string GetSF(string deptCode, string personCode)
        {
            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_dep_per"; //主表库名称
            #region 生成sql语句
            StringBuilder sbSQL = new StringBuilder();
            sbSQL.AppendLine("SELECT ISCWZJ,ISZJL,ISGLY,SF FROM " + strDBTblName + " ");
            sbSQL.AppendLine("WHERE ");
            sbSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            if (!string.IsNullOrEmpty(personCode))
            {
                sbSQL.AppendLine(" AND PERSONCODE = '" + personCode + "' ");
            }
            if (!string.IsNullOrEmpty(deptCode))
            {
                sbSQL.AppendLine(" AND DEPTCODE = '" + deptCode + "' ");
            }
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            //获取数据
            string str = myDB.YookingExecuteJson(strDBGroup, sbSQL.ToString());

        
            if (!"{\"result\":\"yooking null\"}".Equals(str)) 
            {
                JObject o = JArray.Parse(str)[0] as JObject;

                if ("1".Equals(o["ISCWZJ"]?.ToString()) || "1".Equals(o["ISZJL"]?.ToString()) || "1".Equals(o["ISGLY"]?.ToString()))
                {
                    return "2"; // 财务总监或总经理
                }

                if ("1".Equals(o["SF"]?.ToString()))
                {
                    return "1"; // 部门经理
                }
                else
                {
                    return "0";//普通员工
                }
            }
            else
            {
                return "0"; //默认普通员工
            }
        }



        /***
         * 角色权限
         *    unitCode ：单位编码
         *    roleName ：角色名称
         *    depCode  ： 部门编码
         *    PersonnelCode ：人员编码
         */
        public string getPersonnelIdentity(string unitCode, string roleName,string depCode ,string PersonnelCode )
        {


        
            if (roleName.Contains("超级管理员"))
            {

            }
            else if (roleName.Contains("人事管理员"))
            {

            }

            else if (roleName.Contains("财务管理员"))
            {

            }

            else if (roleName.Contains("行政管理员"))
            {

            }
            else if (roleName.Contains("总经理"))
            {

            }
            else if (roleName.Contains("总监"))
            {

            }
            else if (roleName.Contains("部门经理"))
            {

            }
            else { 
            
            
            }

            return "";
        }


        /// <summary>
        /// 得到本部门code
        /// </summary>
        /// <returns></returns>
        public string GetLineMangerAllDeptCode(string userId,string unitCode,string dataAliasName)
        {
            string str = " and (";
            string strDBTblName = "sa_usr_useraccredit"; //库表名称

            string strDBGroup = "Data";
            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.Append("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber,srr.ROLENAME FROM " +
                strDBTblName + " as suu ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_rule_roleinfo as srr ON srr.ROLEID = suu.ROLEID ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_org_staffinfo as sos ON sos.StaffID = suu.STAFFID ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_org_personinfo as op ON op.PERSONID = sos.PERSONID ");
            sbQuerySQL.AppendLine("LEFT JOIN yara_dep_per as p ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(" p.UnitCode='" + unitCode + "' ");
            sbQuerySQL.AppendLine(" and p.PERSONCODE = '" + userId + "' ");

            clsRWFile myLogT = new clsRWFile(); //将待执行的SQL语句记录下来
            myLogT.WriteInfoToTxtFile("SysLog", "fyb20250702.txt", sbQuerySQL.ToString());

            //if (!string.IsNullOrEmpty(userId))
            //{
            //    sbQuerySQL.AppendLine(" AND spuserID = '" + userId + "' ");
            //   // sbTotalySQL.AppendLine(" and  DEPTCODE = '" + DEPTCODE + "' ");
            //}


            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

            DataTable dt=myDB.YookingExecuteDataSet(strDBGroup, sbQuerySQL.ToString()).Tables[0];
            string m = string.Empty;
            string f=string.Empty;
            foreach (DataRow dr in dt.Rows)
            {
                f = dr["DEPTCODE"].ToString();
                m = m + dataAliasName +"='" + dr["DEPTCODE"].ToString()+"'  or ";
            }
            string last =  dataAliasName + "='" + f + "') ";

            str = str + m + last;

            myLogT.WriteInfoToTxtFile("SysLog", "fyb20250702.txt", str +":==13132:");

            return str;

           // return str;
        }

        /***
        * 角色权限
        *    unitCode ：单位编码
        *    roleName ：角色名称
        *    depCode  ： 部门编码
        *    PersonnelCode ：人员编码
        */
        public string getPersonneInfo(string roleName)
        {
            //string strDBGroup = "Data";   //数据库分组名
            //string strDBTblName = "sa_usr_useraccredit"; //库表名称

            //#region 生成查询sql语句
            //StringBuilder sbQuerySQL = new StringBuilder();
            //sbQuerySQL.Append("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber,srr.ROLENAME FROM " +
            //    strDBTblName + " as suu ");
            //sbQuerySQL.AppendLine("LEFT JOIN sa_rule_roleinfo as srr ON srr.ROLEID = suu.ROLEID ");
            //sbQuerySQL.AppendLine("LEFT JOIN sa_org_staffinfo as sos ON sos.StaffID = suu.STAFFID ");
            //sbQuerySQL.AppendLine("LEFT JOIN sa_org_personinfo as op ON op.PERSONID = sos.PERSONID ");
            //sbQuerySQL.AppendLine("LEFT JOIN yara_dep_per as p ON p.PERSONCODE = op.PERSONCODE ");
            //sbQuerySQL.AppendLine("WHERE ");
            //sbQuerySQL.AppendLine(" p.UnitCode='" + UnitCode + "' ");
            //sbQuerySQL.AppendLine("op.PERSONID = '" + PersonnelCode + "' ");



            /// SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber,srr.ROLENAME FROM  sa_usr_useraccredit as suu

            // LEFT JOIN sa_rule_roleinfo as srr ON srr.ROLEID = suu.ROLEID
            //LEFT JOIN sa_org_staffinfo as sos ON sos.StaffID = suu.STAFFID
            //LEFT JOIN sa_org_personinfo as op ON op.PERSONID = sos.PERSONID
            //LEFT JOIN yara_dep_per as p ON p.PERSONCODE = op.PERSONCODE
            //  WHERE
            // p.UnitCode = 'CHNDSH' and ROLENAME like '%管理员%' GROUP BY WORKNUMBER
            ///

            if (roleName.Contains("超级管理员"))
            {
                return "999";
            }
            else if (roleName.Contains("人事管理员"))
            {
                return "300";
            }

            else if (roleName.Contains("财务管理员"))
            {
                return "100";
            }

            else if (roleName.Contains("行政管理员"))
            {
                return "200";
            }
            else if (roleName.Contains("总经理"))
            {
                return "30";
            }
            else if (roleName.Contains("总监"))
            {
                return "20";
            }
            else if (roleName.Contains("部门经理"))
            {
                return "10";
            }
            else
            {
                return "0";

            }
        }



        public string GetBuySPList(string strB64RequestData)
        {
            string strRtData = "no data";
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_buy_property"; //主表库名称
            string PersonCode = ""; //申批人的id
            string UnitCode = ""; //公司的unitCode
          
            //这些参数用★分隔开，客户端与服务器端要一致   8 9 (部门id-人员id)
            string[] strArray = strRequestData.Split('★');

            PersonCode =strArray[0].ToString();
            UnitCode = strArray[1].ToString();


           //获取符合条件的总条数

            //这些参数用★分隔开，客户端与服务器端要一致   8 9 (部门id-人员id)



            //获取符合条件的总条数

            #region 统计总条数
            StringBuilder sbTotalySQL = new StringBuilder();
            sbTotalySQL.AppendLine("SELECT COUNT(*) AS total FROM " + strDBTblName);
            sbTotalySQL.AppendLine(" WHERE ");
            sbTotalySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbTotalySQL.AppendLine(" AND UnitCode = '" + UnitCode + "' ");
            if (!string.IsNullOrEmpty(PersonCode))
            {
                sbTotalySQL.AppendLine(" AND modelDescribe like '%" + PersonCode + "%' "); ///modelDescribe 与模板中查询
            }

            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            myLog.WriteInfoToTxtFile("SysLog", "fyb1212.txt", sbTotalySQL.ToString());

            string str = myDB.YookingExecuteJson(strDBGroup, sbTotalySQL.ToString());
            JObject o = new JObject();

            JObject oo = JArray.Parse(str)[0] as JObject;
            //if ("0".Equals(oo["total"].ToString()))
           // {
            //    o.Add("totalNum", 0);
            //    o.Add("list", new JArray());
           // }
           // else
           // {
                //起始条数
                #region 生成查询sql语句
                StringBuilder sbQuerySQL = new StringBuilder();
                sbQuerySQL.AppendLine("SELECT buyID,p.IsNullSN,d.IsZP,p.typeName,d.procurementType,d.spuserID, taxRate,budgetUnitPrice, d.TypeID, userID, userName, userDepartmentID,userDepartment, purchaseOrderNumber,propertyName,brand,modelNumber,number,state,applicantName,procurementTime,dqsNum, budgetUnitPrice, d.SYS_RECORDID AS strRecordID, modelDescribe,d.description,spYJ,Dstate,Dinfo FROM " + strDBTblName + " AS d ");
                sbQuerySQL.AppendLine(" LEFT JOIN yara_type_property AS p ON p.typeID = d.TypeID ");
                sbQuerySQL.AppendLine(" WHERE ");
                sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
                sbQuerySQL.AppendLine(" AND d.UnitCode = '" + UnitCode + "' ");
              
                if (!string.IsNullOrEmpty(PersonCode))
                {
                    sbQuerySQL.AppendLine(" AND d.modelDescribe like '%" + PersonCode + "%' ");
                }
                
                sbQuerySQL.AppendLine("ORDER BY d.Sys_InputDateTime DESC ");

            #endregion
            //获取列表详情

            myLog.WriteInfoToTxtFile("SysLog", "fyb1212.txt", sbQuerySQL.ToString());
            string listStr = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());
                JArray list = JArray.Parse(listStr);
            foreach (JObject i in list)
            {
                StringBuilder sbCountSQL = new StringBuilder();
                sbCountSQL.AppendLine("SELECT p.typeName as typeNameCount , COUNT(d.detailID) AS total FROM yara_property_detail AS d ");
                sbCountSQL.AppendLine("LEFT JOIN yara_type_property AS p ON p.typeID = d.TypeID ");
                sbCountSQL.AppendLine("WHERE ");
                sbCountSQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
                sbCountSQL.AppendLine(" AND d.TypeID = '" + i["TypeID"] + "' ");
                sbCountSQL.AppendLine(" AND d.departmentID = '" + i["userDepartmentID"] + "' ");

                string count = myDB.YookingExecuteJson(strDBGroup, sbCountSQL.ToString());
                if ("{\"result\":\"yooking null\"}".Equals(count))
                {
                    i.Add("count", 0);
                    i.Add("typeNameCount", "");
                }
                else
                {
                    JObject ooo = JArray.Parse(count)[0] as JObject;
                    i.Add("count", ooo["total"].Value<int>());
                    i.Add("typeNameCount", ooo["typeNameCount"].ToString());
                }
            }
            o.Add("totalNum", oo["total"].Value<int>());
            o.Add("list", list);

            //}
            strRtData = o.ToString();
            return strRtData; //数据库查询结果
        }

        /// <summary>
        /// 查询最后一次盘点的编号，用于盘点报表的查询，默认仅显示最后一次的盘点情况
        /// </summary>
        /// <returns></returns>
        public string GetInventorySetListByUnitCode(string strB64RequestData)
        {
            string strRtData = "no data";
            string PersonCode = "";
            string UnitCode = "";
            clsRWFile myLo1g = new clsRWFile();
            // clsRWFile myLo1g = new clsRWFile(); //将待执行的SQL语句记录下来
            // myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt", strB64RequestData.ToString());


            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_inventory_set"; //主表库名称
            string[] strArray = strRequestData.Split('★');
            //这些参数用★分隔开，客户端与服务器端要一致 `${PersonCode}★${ObjToStr(localStorage_getValue("UnitCode"))}`;  
            // string[] strArray = strRequestData.Split('★');  SELECT  InventoryNumber From  yara_inventory_set  ORDER BY  Sys_InputDateTime

     
            PersonCode = strArray[0];
            UnitCode = strArray[1];
            // clsRWFile myLo1g = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt", UnitCode.ToString());  typeID AS value,pID, typeName AS label, 


            #region 生成查询sql语句
            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT  InventoryNumber as label,InventoryNumber AS value  FROM " + strDBTblName + " ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND Unitcode = '" + UnitCode + "' ");
            //sbQuerySQL.AppendLine(" AND procurementType = '" + procurementType + "' ");
            sbQuerySQL.AppendLine("  ORDER BY  Sys_InputDateTime desc ");

            myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt", sbQuerySQL.ToString());
            #endregion
            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
                                                      //获取列表字符串
            string str = myDB.YookingExecuteJson(strDBGroup, sbQuerySQL.ToString());



            if (!"{\"result\":\"yooking null\"}".Equals(str))
            {
      
                myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt"," yooking null");

                //    JArray arr = JArray.Parse(str);
                //    JArray arr2 = new JArray();//一级列表
                //    foreach (JObject item in arr)
                //    {
                //        if ((string)item["pID"] == "0")
                //        {
                //            arr2.Add(item);
                //        }
                //    }
                //    foreach (JObject item in arr2)
                //    {
                //        JArray arr3 = new JArray();//二级列表
                //        foreach (JObject item1 in arr)
                //        {
                //            if ((string)item1["pID"] == (string)item["value"])
                //            {
                //                arr3.Add(item1);
                //            }
                //        }
                //        item.Add("children", arr3);
                //    }
                //    strRtData = arr2.ToString();
                //}
                //else
                strRtData = str;
            }
            else
            {
                strRtData = new JArray().ToString();
            }
            return strRtData; //数据库查询结果


        }



        /// <summary>
        /// 任务执行，由任务定时调用
        /// </summary>
        /// <returns></returns>
        public string RunTask( string strB64RequestData)
        {
          
            string rdt = string.Empty;
            string[] UnitCode = { "CHNDSH", "CHNDFC" };
            for (int i = 0; i < UnitCode.Length; i++)
            {
                GetDataBySqlstr(UnitCode[i]);
            }


            YookingFileIO.Class.clsRWFile rwf = new clsRWFile();
            rwf.DeleteOldFiles("/yks/app/client/pcClient/public/file/report/", 90);  //删除超过90天的文件


            return rdt;
        }


        public void Write_yara_fixedtime_msg_Data(string msgTitle,string msgContent, string filename, string UnitCode)
        {

           string  strDBTblName = "sa_usr_useraccredit";
            StringBuilder sbQuerySQL = new StringBuilder();

            string Url = filename.Replace("/yks/app/client/pcClient/", "https://www.yara-ams.com/");


            //SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber,srr.ROLENAME FROM  sa_usr_useraccredit as suu

            //LEFT JOIN sa_rule_roleinfo as srr ON srr.ROLEID = suu.ROLEID
            //LEFT JOIN sa_org_staffinfo as sos ON sos.StaffID = suu.STAFFID
            //LEFT JOIN sa_org_personinfo as op ON op.PERSONID = sos.PERSONID
            //LEFT JOIN yara_dep_per as p ON p.PERSONCODE = op.PERSONCODE
            //  WHERE
            // p.UnitCode = 'CHNDSH' and ROLENAME like '%管理员%'
            //and srr.ROLENAME<> '人事管理员'
            //GROUP BY WORKNUMBER 

            sbQuerySQL.AppendLine("SELECT p.DEPTCODE,p.DEPTNAME,p.PERSONCODE,p.PERSONNAME as personName,p.ISCWZJ,p.ISZJL,p.SF,p.gzhOpenid,op.email,p.userName,op.WorkNumber,srr.ROLENAME FROM " + strDBTblName + " as suu  ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_rule_roleinfo as srr ON srr.ROLEID = suu.ROLEID  ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_org_staffinfo as sos ON sos.StaffID = suu.STAFFID  ");
            sbQuerySQL.AppendLine("LEFT JOIN sa_org_personinfo as op ON op.PERSONID = sos.PERSONID ");
            sbQuerySQL.AppendLine("LEFT JOIN yara_dep_per as p ON p.PERSONCODE = op.PERSONCODE ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL("Data", "suu.SYS_CANCELDATETIME  "));
            sbQuerySQL.AppendLine(" AND p.UnitCode = '" + UnitCode + "' ");
            sbQuerySQL.AppendLine(" and ROLENAME like '%管理员%'  ");
            sbQuerySQL.AppendLine("GROUP BY op.WORKNUMBER ");

            try
            {
                clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类

                string list = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());


                strDBTblName = "yara_fixedtime_msg";
                JArray arr = JArray.Parse(list);
                JArray strJsonArray = new JArray();

                foreach (JObject obj in arr)
                {
                    JObject o = new JObject();
                    o.Add("ID", Guid.NewGuid().ToString());
                    o.Add("wxGzhOpenid", obj["gzhOpenid"]);
                    o.Add("email", obj["email"]);
                    o.Add("annexUrl", Url);
                    o.Add("msgType", "");
                    o.Add("msgTitle", msgTitle);
                    o.Add("msgContent", msgContent);
                    o.Add("infoID", "");
                    o.Add("isSending", "0");
                    o.Add("templateType", "");
                    o.Add("setSenTime", "");
                    o.Add("senTime", "09:15:00");
                    o.Add("workNumber", obj["WorkNumber"]);
                    strJsonArray.Add(o);
                }


                DataSet dsData = clsJConvert.JArryToDataSet(strJsonArray.ToString()); //将Json数组转成DataSet
                clsWriteDB myWrite = new clsWriteDB(); //先判断数据是否存在，根据判断结果自动执行insert或者update
                myWrite.WriteDBNormal_UseSYSCol("Data", strDBTblName, "ID", "02120119901", dsData);


            }
            catch (Exception e)
            {

                clsRWFile myLo1g = new clsRWFile(); //将待执行的SQL语句记录下来
                myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt",e.Message.ToString()+" /n 写入定时表出错" );
            }




        }

        public string GetDataBySqlstr(string UnitCode)
        {
            string strRtData = "no data";
            string PersonCode = "";
            //string unitCode = "";
            clsRWFile myLo1g = new clsRWFile();//临时记录log文件
            string html=string.Empty;
          


           // string eDate = System.DateTime.Now..ToString("yyyy-MM-dd");//获取当前年月
            string eDate = DateTime.Now.Year.ToString()+"-"+ DateTime.Now.Month.ToString()+"-25";
            string sDate = DateTime.Now.Year.ToString() + "-" +(Convert.ToInt16(DateTime.Now.Month)-1).ToString() + "-25";
            // string sDate = System.DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd");
            // clsRWFile myLo1g = new clsRWFile(); //将待执行的SQL语句记录下来
            // myLo1g.WriteInfoToTxtFile("SysLog", "fyb1.txt", strB64RequestData.ToString());       
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            //string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            string strDBGroup = "Data";   //主表数据库分组名
            string strDBTblName = "yara_inventory_set"; //主表库名称

            StringBuilder sbQuerySQL = new StringBuilder();
            //string[] strArray = strRequestData.Split('★');
           // PersonCode = strArray[0];
            //UnitCode = strArray[1];

            ///////////////////////////////////////////////////////////////////////////////
            ///-----------采购start
            /////////////////////////////////////////////////////////////////////////////

            strDBTblName = "yara_property_detail";
            sbQuerySQL.Clear();//清除原数据

            sbQuerySQL.AppendLine("SELECT d.propertyNumber,d.propertyName,d.receiptTime,d.brands,d.modelNumber,d.serialNumber,d.userName,p.WorkNumber,d.departmentName,d.depreciationMonthStart,d.ScrapTime,d.propertyPrice,d.state  FROM " + strDBTblName + " AS d ");
            sbQuerySQL.AppendLine("LEFT JOIN Sa_Org_PersonInfo AS p ON p.PERSONCODE = d.userID ");
            sbQuerySQL.AppendLine("LEFT JOIN yara_type_property AS tp ON tp.typeID = d.TypeID ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "d.SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND d.UnitCode = '" + UnitCode+ "' ");
          
            if (!string.IsNullOrEmpty(sDate))
            {
                sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(d.Sys_InputDateTime, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }
            sbQuerySQL.AppendLine("ORDER BY d.Sys_InputDateTime DESC ");

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
             myLo1g.WriteInfoToTxtFile("SysLog", "TestJosonToExcel.txt", sbQuerySQL.ToString() + "  :采购start" + DateTime.Now);

            DataTable dt = myDB.YookingExecuteDataSet(strDBGroup, sbQuerySQL.ToString()).Tables[0];

            string fileName=dataTableToCsvCG(dt, "CG").ToString(); //得到采购的csv文件全名

             //string URL= fileName.Replace("/yks/app/client/pcClient/", "https://www.yara-ams.com/");

          //  html = html + "<a href='"+URL+"'>下载文件【入库报表】</a>" + sDate + "至" + eDate + "</br>";


            Write_yara_fixedtime_msg_Data("最新入库表", "本月最新入库清单，请查收！", fileName, UnitCode);
            dt = null;

            ///////////////////////////////////////////////////////////////////////////////
            ///-----------采购end
            /////////////////////////////////////////////////////////////////////////////




            ///////////////////////////////////////////////////////////////////////////////
            ///-----------转移start
            /////////////////////////////////////////////////////////////////////////////
            ///
            #region

            strDBTblName = "yara_fixed_transfer_log";
            sbQuerySQL.Clear();//清除原数据


            sbQuerySQL.AppendLine("SELECT yts.scrapDH,pd.propertyNumber,pd.propertyName, pd.brands, pd.modelNumber, pd.serialNumber, tra.ransferorName, tra.transferAt,tra.shiftToName,  tra.reason, tra.state  FROM " + strDBTblName + " AS tra ");
            sbQuerySQL.AppendLine("LEFT JOIN yara_property_detail AS pd ON tra.detailID = pd.detailID ");
            sbQuerySQL.AppendLine("LEFT JOIN yara_transfer_set AS yts ON tra.scrapSetID = yts.iID ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "tra.SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND tra.UnitCode = '" + UnitCode + "' ");
            if (!string.IsNullOrEmpty(sDate))
            {
                sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(yts.QSDate, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }

             sbQuerySQL.AppendLine("   ORDER BY  tra.Sys_InputDateTime desc ");
            //获取本月转移数量
            //myDB = new clsDbSQLLogic(); //实例化数据库操作类
            myLo1g.WriteInfoToTxtFile("SysLog", "TestJosonToExcel.txt", sbQuerySQL.ToString() + "  :转移start" + DateTime.Now);
            dt =myDB.YookingExecuteDataSet(strDBGroup, sbQuerySQL.ToString()).Tables[0];

             fileName = dataTableToCsvZY(dt, "ZY").ToString();  //得到采购的csv文件全名

         
           Write_yara_fixedtime_msg_Data("本月转移表", "本月转移数据清单，请查收！", fileName, UnitCode);


            ///
            #endregion
            ///////////////////////////////////////////////////////////////////////////////
            ///-----------转移end
            /////////////////////////////////////////////////////////////////////////////
            ///



            ///////////////////////////////////////////////////////////////////////////////
            ///-----------报废start 
            /////////////////////////////////////////////////////////////////////////////
            ///
            //.
            strDBTblName = "yara_scrap";
            sbQuerySQL.Clear();//清除原数据
           // StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine("SELECT   p.propertyNumber,p.propertyName,s.sType,p.brands,p.modelNumber,p.serialNumber,p.ScrapTime,s.faultProblem,s.problemDescription,s.userName,s.PersonName,s.isCompensation,s.CompensationPrice ,s.yuanzhi,s.luruDate,s.RecyclingPrice  from  " + strDBTblName + "  as s  ");
            sbQuerySQL.AppendLine(" LEFT JOIN  yara_property_detail p  on s.propertyID = p.detailID ");
            sbQuerySQL.AppendLine("WHERE ");
            sbQuerySQL.AppendLine(clsSQLSyntax.IsNullSQL(strDBGroup, "s.SYS_CANCELDATETIME "));
            sbQuerySQL.AppendLine(" AND p.UnitCode = '" + UnitCode + "' ");
            if (!string.IsNullOrEmpty(sDate))
            {
                sbQuerySQL.AppendLine(" AND DATE(STR_TO_DATE(p.ScrapTime, '%Y-%m-%d')) BETWEEN '" + sDate + "' AND '" + eDate + "' ");
            }

            myLo1g.WriteInfoToTxtFile("SysLog", "TestJosonToExcel.txt", sbQuerySQL.ToString() + "  :报废start" + DateTime.Now);

            dt = myDB.YookingExecuteDataSet(strDBGroup, sbQuerySQL.ToString()).Tables[0];

            fileName = dataTableToCsvBF(dt, "BF").ToString(); //得到采购的csv文件全名

           // URL = fileName.Replace("/yks/app/client/pcClient/", "https://www.yara-ams.com/");

           // html = html + "<a href='" + URL + "'>下载文件【报废报表】</a>" + sDate + "至" + eDate + "</br>";
           // html = html + "<span style='font-color:red'>*以上文件，请在90内下载完成！超过90天，将不能下周！</span>";

            Write_yara_fixedtime_msg_Data("本月报废表", "本月报废数据清单，请查收！", fileName, UnitCode);


            ///////////////////////////////////////////////////////////////////////////////
            ///-----------报废s 
            /////////////////////////////////////////////////////////////////////////////


            dt = null;


            return strRtData; //数据库查询结果


        }

        /// <summary>
        /// 转移csv
        /// </summary>
        /// <param name="table"></param>
        /// <param name="file"></param>
        public string  dataTableToCsvZY(DataTable table, string file)
        {
            Random random = new Random();
            string filePath = "/yks/app/client/pcClient/public/file/report/"+file+"_" + DateTime.Now.ToString("yyyyMMddHHmmss")+random.Next(1000,9999).ToString()+".csv";
          
            string title = "";
            clsRWFile myLo1g = new clsRWFile();   
            try
            {

                FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(new BufferedStream(fs), System.Text.Encoding.Unicode);

                // 
                //  yts.scrapDH,pd.propertyNumber,pd.propertyName, pd.brands, pd.modelNumber, pd.serialNumber, tra.ransferorName, tra.transferAt,tra.shiftToName,  tra.reason, tra.state

                title += "转移编号 " + Convert.ToChar(9);  //第一列
                title += "资产编号" + Convert.ToChar(9);  //第一列
                title += "资产名称" + Convert.ToChar(9);  //第一列
                title += "品牌" + Convert.ToChar(9);  //第一列
                title += "型号" + Convert.ToChar(9);  //第一列
                title += "机身序号" + Convert.ToChar(9);  //第一列
                title += "转出人" + Convert.ToChar(9);  //第一列
                title += "转出时间" + Convert.ToChar(9);  //第一列
                title += "接收人" + Convert.ToChar(9);  //第一列
                title += "原因" + Convert.ToChar(9);  //第一列
                title += "状态" + Convert.ToChar(9);  //第一列    以上合计9列
                sw.WriteLine(title);

                string line = "";
                foreach (DataRow row in table.Rows)
                {
                    for (int i = 0; i <11; i++)
                    {
                        if (i==10)
                        {
                            if (row[i].ToString().Trim()=="1")
                            {
                                line+="完成转移"+Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                            else
                            {
                                line += "转移中" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                         
                        }
                        else
                        {
                            line += row[i].ToString().Trim() + Convert.ToChar(9); //内容：自动跳到下一单元格
                        }                    
                     
                    }               

                    sw.WriteLine(line);
                    line = "";
          
                }
               // myLo1g.WriteInfoToTxtFile("SysLog", "fyn.txt", "/n" + "fdfdkjfd" + "/n  :获取本月转移数sql语句test" + DateTime.Now);
                sw.Close();
                fs.Close();
            }
            catch (Exception e)
            {

                myLo1g.WriteInfoToTxtFile("SysLog", "ToExcelLog.txt", "/n" + e.Message + "/n  :" + DateTime.Now);
                filePath = "ERROR";
            }


            return filePath;


        }

        /// <summary>
        /// 采购清单 导出csv
        /// </summary>
        /// <param name="table"></param>
        /// <param name="file"></param>
        public string  dataTableToCsvCG(DataTable table, string file)
        {
            Random random = new Random();
            string filePath = "/yks/app/client/pcClient/public/file/report/" + file + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + random.Next(1000, 9999).ToString() + ".csv";

            string title = "";
            clsRWFile myLo1g = new clsRWFile();
            try
            {
                //SELECT d.propertyNumber,d.propertyName,d.receiptTime,d.brands,d.modelNumber,d.serialNumber,d.userName,d.WorkNumber,d.departmentName,d.depreciationMonthStart,d.ScrapTime,d.propertyPrice,d.state

                FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(new BufferedStream(fs), System.Text.Encoding.Unicode);

                title += "资产编号 " + Convert.ToChar(9);  //第一列
                title += "资产名称" + Convert.ToChar(9);  //第一列
                title += "入库日期" + Convert.ToChar(9);  //第一列
                title += "品牌" + Convert.ToChar(9);  //第一列
                title += "型号" + Convert.ToChar(9);  //第一列
                title += "序列号" + Convert.ToChar(9);  //第一列
                title += "使用人" + Convert.ToChar(9);  //第一列
                title += "工号" + Convert.ToChar(9);  //第一列
                title += "使用部门" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "部门名称" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "PAF日期" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "报废月份" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "原值" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "状态" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "状态" + Convert.ToChar(9);  //第一列    以上合计9列

                sw.WriteLine(title);

                string line = "";
                foreach (DataRow row in table.Rows)
                {
                    for (int i = 0; i < 13; i++)
                    {
                        if (i == 12)
                        {
                            if (row[i].ToString().Trim() == "1")
                            {
                                line += "正常" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                            else
                            {
                                line += "报废" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }

                        }
                        else
                        {
                            line += row[i].ToString().Trim() + Convert.ToChar(9); //内容：自动跳到下一单元格
                        }

                    }

                    sw.WriteLine(line);
                    line = "";

                }
                // myLo1g.WriteInfoToTxtFile("SysLog", "fyn.txt", "/n" + "fdfdkjfd" + "/n  :获取本月转移数sql语句test" + DateTime.Now);
                sw.Close();
                fs.Close();
               
            }
            catch (Exception e)
            {

                myLo1g.WriteInfoToTxtFile("SysLog", "ToExcelLog.txt", "/n cg:" + e.Message + "/n  :" + DateTime.Now);
                filePath = "ERROR";
            }


            return filePath;

        }


        /// <summary>
        /// 报废清单导出csv
        /// </summary>
        /// <param name="table"></param>
        /// <param name="file"></param>
        public string dataTableToCsvBF(DataTable table, string file)
        {
            Random random = new Random();
            string filePath = "/yks/app/client/pcClient/public/file/report/" + file + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + random.Next(1000, 9999).ToString() + ".csv";

            string title = "";
            clsRWFile myLo1g = new clsRWFile();
            try
            {
                // SELECT   p.propertyNumber,p.propertyName,s.sType,p.brands,p.modelNumber,p.serialNumber,p.ScrapTime,s.faultProblem,s.problemDescription,
                // s.userName,s.PersonName,s.isCompensation,s.CompensationPrice ,s.yuanzhi,s.luruDate,s.RecyclingPrice 


                FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(new BufferedStream(fs), System.Text.Encoding.Unicode);

                title += "资产编号 " + Convert.ToChar(9);  //第一列
                title += "资产名称" + Convert.ToChar(9);  //第一列
                title += "收购类型" + Convert.ToChar(9);  //第一列
                title += "品牌" + Convert.ToChar(9);  //第一列
                title += "型号" + Convert.ToChar(9);  //第一列
                title += "机身序号" + Convert.ToChar(9);  //第一列
                title += "报废日期" + Convert.ToChar(9);  //第一列  
                title += "报废原因" + Convert.ToChar(9);  //第一列
                title += "问题描述" + Convert.ToChar(9);  //第一列
                title += "申请人员" + Convert.ToChar(9);  //第一列
                title += "回收单位" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "是否赔偿" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "赔偿价格" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "原值" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "PAF录入日期" + Convert.ToChar(9);  //第一列    以上合计9列
                title += "回收价格" + Convert.ToChar(9);  //第一列    以上合计9列


                sw.WriteLine(title);

                string line = "";
                foreach (DataRow row in table.Rows)
                {
                    for (int i = 0; i < 15; i++)
                    {
                        if (i == 9)
                        {
                            if (row[i].ToString().Trim() == "1")
                            {
                                line += "完成转移" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                            else
                            {
                                line += "转移中" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }

                        }
                        else if (i == 2)
                        {
                            if (row[i].ToString().Trim() == "1")
                            {
                                line += "内部回收" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                            else
                            {
                                line += "第三方公司" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }

                        }
                        else if (i == 11)
                        {
                            if (row[i].ToString().Trim() == "1")
                            {
                                line += "是" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                            else
                            {
                                line += "否" + Convert.ToChar(9); //内容：自动跳到下一单元格
                            }
                        }
                        else
                        {
                            line += row[i].ToString().Trim() + Convert.ToChar(9); //内容：自动跳到下一单元格
                        }

                    }

                    sw.WriteLine(line);
                    line = "";

                }
                // myLo1g.WriteInfoToTxtFile("SysLog", "fyn.txt", "/n" + "fdfdkjfd" + "/n  :获取本月转移数sql语句test" + DateTime.Now);
                sw.Close();
                fs.Close();
            }
            catch (Exception e)
            {

                myLo1g.WriteInfoToTxtFile("SysLog", "ToExcelLog.txt", "/n" + e.Message + "/n  :" + DateTime.Now);
                filePath = "ERROR";
            }


            return filePath;


        }
    }
}